Download & Extend

Autocomplete fires on readonly fields

Project:Drupal core
Version:6.x-dev
Component:javascript
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Issue tags:needs backport to D6, needs backport to D7

Issue Summary

If you have a readonly textfield with an autocomplete path, the autocomplete request fires when the user places the cursor in the field and presses any key, even though the textfield is readonly.

The use case for this is to have an autocomplete textfield that you want to enable through some other means (checkbox or other field filled in beforehand). In that case, you don't want the autocomplete to fire until the field is actually writeable.

I have attached an SVN patch with the hack that we will include on our platform, but since it uses jQuery() directly in the autocomplete's prototype context, I really don't think it is the best solution - but it's the best that I could come up with at that point in the code - I could perhaps have done something within the populatePopup() method itself, but I feel that it belongs with the check for input.value.length > 0

I would love it, if someone better at javascript/prototype/autocomplete could come up with a better solution.

AttachmentSizeStatusTest resultOperations
autocomplete.js_.diff439 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch autocomplete.js_.diff. Unable to apply patch. See the log in the details link for more information.View details | Re-test

Comments

#1

Version:7.14» 8.x-dev
Component:ajax system» javascript
Priority:minor» normal

That would be the best way to fix it, need to be fixed in D8 first.

#2

Status:active» needs review

Btw. it seems some browsers already implement this behaviour that they do not fire events when the field is read-only (in Opera, it seems it's like that, for example)

AttachmentSizeStatusTest resultOperations
1631164_autocomplete_ro-2.patch453 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 36,847 pass(es).View details | Re-test

#3

There is no tricks with the readonly value, you don't need to go through jQuery to get it.

#4

Indeed.

AttachmentSizeStatusTest resultOperations
1631164_autocomplete_ro-4.patch437 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 36,850 pass(es).View details | Re-test

#5

Status:needs review» reviewed & tested by the community

Thanks :)

#6

Version:8.x-dev» 7.x-dev

Committed to 8.x. Thanks!

Moving to 7.x.

#7

Status:reviewed & tested by the community» needs work

#8

Status:needs work» reviewed & tested by the community

re-rolled to the 7.x trivially

AttachmentSizeStatusTest resultOperations
1631164_autocomplete_ro-8-only-condition.patch436 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 39,252 pass(es).View details | Re-test
1631164_autocomplete_ro-8.patch501 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 39,237 pass(es).View details | Re-test

#9

Wait. I'm confused. Which patch is for 7.x?

#10

Both. One of them only fixes the logical flaw only, the other one fixes some core beauty issue as well.

#11

Status:reviewed & tested by the community» fixed

Committed to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/41f11d4

#12

Version:7.x-dev» 6.x-dev
Status:fixed» patch (to be ported)
Issue tags:+needs backport to D6

Actually, I guess this is an issue in D6 too.

#13

Status:patch (to be ported)» needs review
AttachmentSizeStatusTest resultOperations
1631164-autocomplete_ro-6.x-13.patch500 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 190 pass(es).View details | Re-test
nobody click here