Okay, considering how no one gives a damn about page optimization (does that mean I should reset my code..??), let's go back on topic...
I'm having some trouble with the onchange event on select boxes.
Basically, in a regular select box, the change event is triggered when you click a different entry in the list. Okay.
When it comes to keyboard navigation, it's more complicated... You focus on the select box (tab), press Space to open it (I don't know why it didn't work a few days ago...), you navigate with the keys, and you press Enter. ONLY when you press enter, will the display area be modified and the onchange event be triggered.
That is, if you (a) press SPACE to close the select box, or (b) press TAB to switch to another select box, the current selection is cancelled (i.e. not reflected in the display area), the list box is closed, and either gets the focus (space), or the next form element gets the focus (tab).
Now, if the select box is closed but focused, using arrow keys will navigate the list and fire an onchange event every time, which isn't great when said event tends to jump to a new page or whatever (because you then have no idea what you selected that resulted in this action), so I don't want to do that.
The 'solution' would be to rewrite the code to behave like a regular select box, and simply open the list box when navigating, i.e. never navigate without the list box opened. The only drawbacks are: (1) it takes more code (although at this point, it's not a big deal), and (2) when the onchange event would usually change the form's appearance, e.g. the custom field creator, where you switch between social media profiles like Facebook, if the select box is focused but not opened, pressing the down arrow key will immediately update the entire form with placeholders for these sites. Which, really, is pretty cool... But I'm not sure there's a point in that, except the fact that it looks cool.
Fishing for opinions...
Posted: December 29th, 2011, 06:24 PM
:edit: Moved this topic to public... Not exactly sure why I created it in the private area.