Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
If a user has selected an item from the DER widget autocomplete dropdown and then subsequently changes the entity type selected, the previously selected entity will now be invalid and will throw an error if the user then tries to submit the form. Obviously there's an easy workaround to manually clear the field value but it would be fairly easy to clear it via JS on change.
Proposed resolution
Enhance the dynamicEntityReferenceWidgetSelect JS function to clear the autocomplete field.
Remaining tasks
Tests
Code
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff-5-8.txt | 610 bytes | acbramley |
#8 | 2906492-8.patch | 4.31 KB | acbramley |
|
Comments
Comment #2
jibranI think it is a bug.
Comment #3
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedWorking on this today.
Comment #4
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedHere's a failing test. I couldn't get the tests to work without selecting the autocomplete option. It's something to do with the dropdown not disappearing when selecting the new entity type. Even with
$autocomplete_field->keyDown(self::ESCAPE_KEY);
it wasn't dropping off.Comment #5
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedAnd the fix.
Comment #7
fenstratNice one, LGTM.
Assuming things fail without this?
Comment #8
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedRemoved the sleep(1) call.
Comment #9
fenstratGreat!
Comment #12
jibranThanks, committed and pushed to both branches.