Problem/Motivation
I'm on drupal.org commenting on an issue, or in general using a node edit form in Drupal.
I want to change one of the tags from the existing "Needs Documentation" to "Needs Update Documentation". It's in the middle of a list of tags the issue has been tagged with. Let's say the list is API Change, Needs Documentation, UI Freeze.
I go to where Needs Documentation is and start typing Update in the middle of that tag.
In Drupal 7: I get a type-ahead drop-down box, but it contains suggestions for the UI Freeze tag, not the tag I am actually editing.
In Drupal 8: No suggestions are offered at all in the middle of the list.
To reproduce in a clean Drupal install:
- Install with Standard profile.
- Go to node/add/article to add a new Article. Create one with several tags, such as cat, dog, fish, gerbil
- Create a new article. Go to the Tags field. Type in a tag or two, then go back and attempt to edit one of the earlier tags.
Proposed resolution
Fix the auto-complete so that it detects where you are in the tag list, looks for suggestions matching the tag you are in, and puts the replacements in the right place when you're done choosing your selection.
Remaining tasks
Make a viable patch with tests.
User interface changes
The tag auto-complete will work properly when you're in the middle of a tag list.
API changes
Probably none.
Comment | File | Size | Author |
---|---|---|---|
#48 | autocomplete_cursor-992020-48.patch | 9.3 KB | dags |
#48 | interdiff.txt | 4.6 KB | dags |
#46 | autocomplete_cursor-992020-46.patch | 9.07 KB | dags |
#43 | autocomplete_cursor-992020-43.patch | 9.08 KB | muka |
#41 | autocomplete_cursor-992020-35.patch | 8.68 KB | muka |
Comments
Comment #1
drummComment #2
mr.baileysComment alter taxonomy just re-uses Taxonomy's forms and auto-complete logic, so this is not the correct queue. Seems that the same behavior occurs on standard D6 and D7 sites wherever a free-tagging vocabulary is used and without project_issue/comment_alter_taxonomy.
The taxonomy auto-complete seems to always auto-complete the last item in the list instead of respecting the cursor to see which term is being edited (see D7 screenshot below)
Comment #3
jhodgdonThanks for investigating. This looks like something we should fix in D7, and kind of a major usability issue? Even though it was also broken in D6, it still seems major to me.
Comment #4
rfaysubscribe.
Actually, autocomplete has not had enough attention over time and there are a number of issues open for it.
Comment #5
chx CreditAttribution: chx commentedComment #6
stBorchertHere is a first working patch. If you edit a tag in the list its text will be used to search matching terms.
See https://img.skitch.com/20110604-fx6du4sy8pxrjq5mc57texpy4q.png
Comment #8
jhodgdonStrange test glitch: failed to retrieve [autocomplete_caret_position-992020-6.patch] from [].
Comment #9
jhodgdon#6: autocomplete_caret_position-992020-6.patch queued for re-testing.
Comment #11
boombatower CreditAttribution: boombatower commentedSeems something on d.o didn't give PIFT the proper URL to send over to qa.d.o. Hmm.
Created #1178406: All tests failing: Relative patch file path used instead of absolute in patch testing.
Comment #12
rfayJust to see if it's some unexpected thing about file naming, here's the same patch with a different name. This is the same as #6.
Comment #14
stBorchertSeems like PIFR didn't use the full path to the file ("//" in the beginning of path instead of a single "/").
https://img.skitch.com/20110604-ddu6xgxfgnfw5a4691t75dsh4q.png
Comment #15
stBorchertNext try with PIFR ...
Comment #17
stBorchertNext try with minor fix to prevent errors in test case.
Comment #18
chx CreditAttribution: chx commentedThanks for fixing this rather pesky issue. While the JS cant be tested easily surely you could emulate the requests JS will make and verify results.
Comment #19
stBorchertFirst try with one simple test case.
Comment #20
stBorchert#19: autocomplete_caret_position-992020-19.patch queued for re-testing.
Comment #21
stBorchert#19: autocomplete_caret_position-992020-19.patch queued for re-testing.
Comment #23
stBorchertUpdated patch to latest head.
Comment #24
xjmRerolled for core/ with a slight doxygen correction.
Comment #25
jhodgdonI read this patch over with regards to documentation.
I would like to suggest renaming the "caret position" variables and arguments to "cursor position". I've never heard of it being called a "caret"? This also applies to some in-code comments.
Also, this docblock is not up to standards at all:
http://drupal.org/node/1354#functions
Other docblocks could use some @param/@return docs, but this one is particularly bad.
Comment #26
xjm#25 I noticed that as well, but those lines aren't part of the patch change, so should be fixed in a separate issue. I am expecting taxonomy.module cleanup to take care of that.
I am also -1 on "caret".
Comment #27
xjmEh I'll just rename the variable myself. :)
Comment #28
jhodgdonRegarding the docblocks, several functions have arguments that are being changed in this patch. Their docblocks should be updated, and the new parameters should be documented. I realize that the former docblocks were garbage, but that is not (I think) a good reason not to document the functions now, especially since the new parameters may not be obvious what they are. They should be documented now.
Comment #29
xjmThe attached patch replaces the word "caret" with "cursor" and also polishes the inline comments a bit. I didn't touch the docblock for
taxonomy_autocomplete()
for the reasons stated in #26, but I made note of it in #1326644: Clean up API docs for taxonomy module.The patch includes automated tests already. However, since this is JS functionality, we should have a few people test the functionality and report the results. Tagging as novice for manual review and testing.
Comment #30
xjm#28 Oh! Now I understand what you mean. Okay, fixing that. Sorry. :)
Comment #31
xjmOpened #1337124: Improve API documentation for taxonomy_autocomplete().
Comment #32
xjmNow that #1337124: Improve API documentation for taxonomy_autocomplete() is in, here's a reroll that adds documentation for the additional parameter.
Comment #33
xjmComment #34
theamoeba CreditAttribution: theamoeba commentedI have tested this patch on minimal-8.0-dev.
I created a taxonomy vocabulary called Testing.
I then populated it it with three terms: Alpha, Beta, Gamma.
I created a content type called Page and added the term reference field as an autocomplete term widget (tagging).
Before implementing the patch in #32 I could replicated this issue.
After implementing the patch and clearing the cache I saw the following behavior: the patch fixes the issue respecting the cursor position but when selecting a suggested term it appends it to the end which is confusing to the user.
Comment #35
xjmThanks @theamoeba. That's a perfect test writeup. :)
I think we should change the function so it also orders the terms as expected after autocomplete. As @theamoeba pointed out in IRC, it becomes a usability issue.
Comment #36
xjmFrom IRC:
See also:
http://docs.jquery.com/UI/Autocomplete
http://jqueryui.com/demos/autocomplete/
Per Dave Reid there's an issue to replace our autocomplete with that in D8.
Comment #37
muka CreditAttribution: muka commentedHi,
here a revision of the patch #32 by xjm. It miss the autocomplete tests in taxonomy.test as I didn't found the appropriate code.
Comment #38
xjmSetting NR for the bot. Thanks @muka!
Comment #39
xjmComment #41
muka CreditAttribution: muka commentedReviewed to add tests too
Comment #43
muka CreditAttribution: muka commentedRerolled.
Comment #45
dags CreditAttribution: dags commentedComment #46
dags CreditAttribution: dags commentedReroll.
Comment #48
dags CreditAttribution: dags commentedMoving test into subclass to reduce number of fails. I'm also taking this off of myself for someone else to work on fixing the test failures.
Comment #50
tim.plunkettThis will always fail the first time around, since -1 is never valid.
With this change, $term_matches can now be empty, whereas before it wasn't.
Comment #51
bas.hr CreditAttribution: bas.hr commentedShould we postpone this until #675446: Use jQuery UI Autocomplete is resolved?
Comment #52
nod_Yep, that would make sense.
Comment #53
jhodgdonIt might make sense for Drupal 8.x, but it doesn't make sense for Drupal 7.x, where this is a long-standing and fairly annoying bug that will need to be fixed in the existing code. Can we consider not postponing it after all?
Comment #54
nod_Oh right, D7 slipped out of my mind. Sorry about that.
Comment #55
droplet CreditAttribution: droplet commentedthe backend parser is borken as well. It may affect testbot result. #1329742: Autocomplete with tagging silently discards invalid input
Comment #56
tkoleary CreditAttribution: tkoleary commentedPlease follow progress on: #2346973: Improve usability, accessibility, and scalability of long select lists
Changing to Select2 may render this issue obsolete
Comment #57
heddnLet's triage this a little more and see if
Comment #58
jhodgdonI just updated the issue summary with clear steps to reproduce.
It is in fact still an issue in Drupal 8, where the auto-complete does not work at all in the middle of the list.
Comment #59
jhodgdonComment #60
tkoleary CreditAttribution: tkoleary at Acquia commentedAs of beta 10 I can no longer reproduce this.
Maybe it was solved by jquery update.
Comment #61
jhodgdonIn that case, we need to move it down to D7, where it is still a bug (which affects drupal.org among other things).
Comment #62
jhodgdonActually, I think it is still an issue in Drupal 8. If you try to edit a tag in the middle of the taxonomy list, you get no suggestions at all. That is what is in the issue summary. Seems to behave the same now in 8.0.x
Comment #63
tkoleary CreditAttribution: tkoleary at Acquia commentedOK, I see now. I misunderstood the summary.
This issue would be solved in 8 by using Select2 if that issue lands #2346973: Improve usability, accessibility, and scalability of long select lists, which it could even in 8.1 since it does not impact backwards compatibility AFAICT.
IMO that's where we should put the effort and not waste time with a half-way fix to a problem for which there is a simple work around (delete the tag and start typing again at the end of the list).
Comment #64
andypostRelated issue #2186643: Autocomplete always searches the last tag (probably duplicate of this)
Comment #66
jhodgdonI attempted a while back to close #2186643: Autocomplete always searches the last tag as a duplicate of this issue. But at least one person there wanted to close this one instead. OK. Anyone on this issue that wants patch credit should put their patch on the other issue, which is newer but whatever.