Closed
Bug 1498769
Opened 6 years ago
Closed 6 years ago
<option> elements with "display: none" style can still be selected using the keyboard
Categories
(Core :: Layout: Form Controls, defect)
Tracking
()
RESOLVED
FIXED
mozilla64
Tracking | Status | |
---|---|---|
firefox64 | --- | fixed |
People
(Reporter: zrhoffman, Assigned: MatsPalmgren_bugz)
References
Details
Attachments
(2 files, 2 obsolete files)
147 bytes,
text/html
|
Details | |
10.31 KB,
patch
|
enndeakin
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0 Steps to reproduce: 1. Open the testcase (or visit data:text/html,<select size="2"><option>Option one</option><option style="display:none">Option two</option><option>Option three</option></select>) 2. Select "Option one" 3. Press the "down" arrow on your keyboard Actual results: No visible <option> element is selected. Notice that if you press "down" a second time, "Option three" will be selected. Expected results: "Option three" should be selected.
Updated•6 years ago
|
Component: Untriaged → Layout: Form Controls
Product: Firefox → Core
Reporter | ||
Updated•6 years ago
|
Summary: When <select> "size" attribute is greater than 1, <option> elements with display: none can still be selected → <option> elements with "display: none" style can still be selected using the keyboard
Comment 1•6 years ago
|
||
Huh, indeed. Weirdly enough we do jump over <option disabled>, so there's code handling this already which probably just needs to be extended to handle this.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Comment 2•6 years ago
|
||
This makes us behave like Chrome for the most part. Chrome handles display:contents "as normal" per spec though: https://drafts.csswg.org/css-display/#unbox-html It appears we currently handle it as display:none, so we need to tweak this a bit once we handle it per spec.
Assignee: nobody → mats
Attachment #9017038 -
Flags: review?(enndeakin)
Reporter | ||
Comment 3•6 years ago
|
||
The code that handles disabled options is nsListControlFrame::AdjustIndexForDisabledOpt(). nsListControlFrame::KeyPress() tests for visibility already by checking if a given option has a frame. We can add that same test to nsListControlFrame::AdjustIndexForDisabledOpt() (and nsListControlFrame::GetNonDisabledOptionFrom() as long as unselecting options when they become invisible is fine).
Attachment #9017039 -
Flags: review?(emilio)
Reporter | ||
Comment 4•6 years ago
|
||
Mats's fix is better, feel free to obsolete mine.
Assignee | ||
Comment 5•6 years ago
|
||
Comment on attachment 9017039 [details] [diff] [review] patch and tests Thanks for the patch Zach - always nice to see new contributors! (sorry to steal this - I didn't know you were working on a fix) Fixing it on a lower level (HTMLSelectElement::IsOptionDisabled) seems better since then we cover all callers, not just keyboard navigation. For example, HTMLSelectElement::SelectSomething etc. Although, Chrome handles that case incorrectly! data:text/html,<select size=1><option style="display:none">Option one</option><option>Option Two</option><option>Option three</option></select>
Attachment #9017039 -
Attachment is obsolete: true
Attachment #9017039 -
Flags: review?(emilio)
Reporter | ||
Comment 6•6 years ago
|
||
You're good. Thanks for fixing it!
Assignee | ||
Comment 7•6 years ago
|
||
I filed https://bugs.chromium.org/p/chromium/issues/detail?id=895171 on Chrome and bug 1498936 on our handling of display:contents on <option>/<optgroup>.
Comment 8•6 years ago
|
||
Comment on attachment 9017038 [details] [diff] [review] fix+test Review of attachment 9017038 [details] [diff] [review]: ----------------------------------------------------------------- Hmm, doesn't this patch break something like setting selectedIndex on something that is out of the document or that has just been added to it but has no frames?
Comment 9•6 years ago
|
||
I think Zach's fix is slightly nicer since it only affects keyboard navigation, not DOM APIs and such. I think DOM APIs should not depend on layout.
Comment 10•6 years ago
|
||
(Also note that my comment above only applies if it breaks stuff as I describe, which I _think_ it does, but only from reading the code, not from actually applying the patch)
Comment 11•6 years ago
|
||
Yeah, this patch definitely breaks testing/web-platform/tests/html/semantics/forms/the-select-element/selected-index.html
Assignee | ||
Comment 12•6 years ago
|
||
Hmm, yeah I think you're right. It seems a bit weird that a <select size=1> auto-selects a display:none <option> that can't be selected by the user, but it seems all UAs agrees on that behavior so...
Assignee | ||
Updated•6 years ago
|
Attachment #9017038 -
Attachment is obsolete: true
Attachment #9017038 -
Flags: review?(enndeakin)
Assignee | ||
Comment 13•6 years ago
|
||
Attachment #9017384 -
Flags: review?(enndeakin)
Assignee | ||
Updated•6 years ago
|
Attachment #9017384 -
Attachment is patch: true
Attachment #9017384 -
Attachment mime type: application/octet-stream → text/plain
Updated•6 years ago
|
Attachment #9017384 -
Flags: review?(enndeakin) → review+
Comment 14•6 years ago
|
||
Pushed by mpalmgren@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/ffba3ac1d2bb Also require a frame for an <option> to be interactively selectable. r=enndeakin
Assignee | ||
Updated•6 years ago
|
Flags: in-testsuite+
Comment 15•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/ffba3ac1d2bb
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in
before you can comment on or make changes to this bug.
Description
•