Opened 12 years ago
Closed 4 years ago
#21258 closed enhancement (worksforme)
Autosuggest for tags suggests tag already chosen
Reported by: | roytanck | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch needs-testing |
Focuses: | javascript, administration | Cc: |
Description
When entering tags in the meta box on a post (or page) edit screen in admin, the AJAX autosuggest will suggest tags that have already been added to the post (i.e. shown below the input field).
Steps to reproduce:
- Go to the post edit screen.
- Add a tag (example: "Apple") to the current post.
- Type "App" in the tag entry field and wait for autosuggest to come up.
- "Apple" is listed in the suggestions dropdown.
I've investigated this a little, and I don't think there's a really easy patch for this (mostly because of how suggest.js works). However, it would imho be very elegant to fix this. Perhaps autocomplete.js can be of service here (see issue #12399)?
Attachments (3)
Change History (11)
#3
@
10 years ago
I discoverd a bug with the items being cached after getting the ajax call.
I now deleted this cache rule, but don't know how much needed this was.
But in the end it would cause to fail my solution if you typed the beginning of a word and pressed enter (added the tag to the list), and then you enter the beginning of this tag again.
To reproduce the problem i had before my last diff:
Add tag: Apple
Begin typing: App
Add this tag with enter without saving the post
Then begin typing: App
With the cache on you again see Apple, now it's solved.
#4
@
10 years ago
- Focuses javascript administration added
- Keywords needs-patch added; needs-testing has-patch removed
Not sure if removing the cache is a good idea. Maybe better to filter in JS? Patching suggest.js
is also not a good idea.
This ticket was mentioned in Slack in #core-editor by afercia. View the logs.
9 years ago
#6
@
7 years ago
It seems previous patch based on suggest.js doesn't apply anymore. The tags suggest functionality moved to /wp-admin/js/tags-suggest.js file.
I'm preparing a patch.
#7
@
7 years ago
- Keywords has-patch needs-testing added; needs-patch removed
I discussed the fix with @adamsilverstein during WCEU contributor day.
Our first approach was to check if the added tags were already available as an object at wp
but we couldn't find it.
As it is just a small fix in a very specific context, I opted to just check the DOM each time we need to filter the set of terms we receive from the server against the ones already added to the post, instead of going to a more pretty solution of having the added tags available as an object, which would need much more logic to maintain it in sync with the DOM (maybe at /wp-admin/js/tags-box.js).
I added the already added tags to the ajax call, and filter them out of the results array.
Here it works perfect on an 4.0 trunk.