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.

Files: 
CommentFileSizeAuthor
#13 1631164-autocomplete_ro-6.x-13.patch500 bytesAron Novak
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View
#8 1631164_autocomplete_ro-8-only-condition.patch436 bytesAron Novak
PASSED: [[SimpleTest]]: [MySQL] 39,252 pass(es). View
#8 1631164_autocomplete_ro-8.patch501 bytesAron Novak
PASSED: [[SimpleTest]]: [MySQL] 39,237 pass(es). View
#4 1631164_autocomplete_ro-4.patch437 bytesAron Novak
PASSED: [[SimpleTest]]: [MySQL] 36,850 pass(es). View
#2 1631164_autocomplete_ro-2.patch453 bytesAron Novak
PASSED: [[SimpleTest]]: [MySQL] 36,847 pass(es). View
autocomplete.js_.diff439 bytesMithrandir
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch autocomplete.js_.diff. Unable to apply patch. See the log in the details link for more information. View

Comments

nod_’s picture

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.

Aron Novak’s picture

Status: Active » Needs review
FileSize
453 bytes
PASSED: [[SimpleTest]]: [MySQL] 36,847 pass(es). View

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)

nod_’s picture

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

Aron Novak’s picture

FileSize
437 bytes
PASSED: [[SimpleTest]]: [MySQL] 36,850 pass(es). View

Indeed.

nod_’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +needs backport to D7

Thanks :)

Dries’s picture

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

Committed to 8.x. Thanks!

Moving to 7.x.

marcingy’s picture

Status: Reviewed & tested by the community » Needs work
Aron Novak’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
501 bytes
PASSED: [[SimpleTest]]: [MySQL] 39,237 pass(es). View
436 bytes
PASSED: [[SimpleTest]]: [MySQL] 39,252 pass(es). View

re-rolled to the 7.x trivially

webchick’s picture

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

Aron Novak’s picture

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

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed
David_Rothstein’s picture

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.

Aron Novak’s picture

Status: Patch (to be ported) » Needs review
FileSize
500 bytes
PASSED: [[SimpleTest]]: [MySQL] 190 pass(es). View

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.