Steps to reproduce:
- Display a nodereference field that uses autocomplete widget as an editable field. It can be on a node page or in a view.
- Place your cursor in the field and enter some data so that the autocomplete dropdown returns some results, use the up/down arrow keys on your keyboard to highlight a result, then press your [Enter] key to select the result.
You will see that the autocomplete field returns this error:
error : [Node Type]: found no valid post with that title.
However, highlighting the result with your mouse and left-clicking the desired result works as expected and does not return an error.
I have a hunch that this has something to do with the [Enter] key triggering node_save on the editable field before the autocomplete result has a chance to populate the field. I would love to submit a patch if I had js skills. But I don't (weeeak) so all I can do is file this report.
Comments
Comment #1
gthing commentedI have the same problem. Enter key should pretty much do nothing on an autocomplete field, except maybe select the top result.
Comment #2
valllabh commentedThis problem is due to Drupal's auto-complete.
If you check update ajax request, it sends value typed by user and not the selected one from auto-complete.
It means input field's change event is getting triggered before auto-complete updates selected value to the input field.
Enter key triggers change event.
Its kind of little hack ;) but It worked for me :P
I tweaked
misc/autocomplete.jsComment #3
ymeiner commentedInstead of being depended on another module's good will and without assuming that all modules are created equal and every programmer is doing his best to fit the code to every other module, here is my solution that involves defensive programming with changes in editablefields.js that solves the [enter] issues. (thank you #2 for the idea)
(This is js for whoever did not understand it)
Comment #4
gthing commentedCould this be implemented as a new module?
Comment #5
ymeiner commentedyou have some options here:
1. rewrite the existing module and replace the code in the js file.
2. put this code in your theme js file.
to write a module just for a js file seams to me like unnecessary work.
Comment #6
Abelito commentedAdding this code to editablefields.js works for me in Drupal 7.
Comment #7
joelpittetClosing this to triage the queue. Feel free to comment if you'd like this to be re-opened, though currently there is nobody supporting the 6.x branch.