Introduce "open" DOM property for <select> element #2072
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
topic: forms
The issue
Related to #263 I've recently been looking at when I can submit a Javascript controlled form when the return key is pressed. For an
<input>
element it is trivial - just submit the form. For a<select>
element this doesn't appear to be possible, nor is implementation behaviour consistent across browsers.When the options are shown (in a
<select>
ofsize=1
) I would like to know if the options list is shown or not. The idea being that if the options are shown then the return key is being used to select an option. If the options list is not shown, the return key is being used to submit the form as with an input element.Currently only Chrome will give the behaviour above, due to the fact that it appears not to trigger
keydown
when the options list is shown. All other browser's will see the return key, but with no way to distinguish if it came from the list being open or not.There are a number of workaround suggestions for this (1, 2, 3) but generally only consider mouse interaction and not keyboard accessibility.
Proposal
Introduce a new
open
(displayed
, or some similar term) property to the<select>
element's DOM interface. This would be a readonly boolean value, where it istrue
while the options list is shown, andfalse
otherwise.This would make it trivial to detect the return key, and decide if the form should be submitted, or it was simply an option selection, in which case it wouldn't submit.
Unresolved
size
> 1 for a<select>
this option is probably useless. What should it do at this point - always betrue
since the list of options is shown?The text was updated successfully, but these errors were encountered: