Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make <select> <button>s have opening behavior by default
This patch makes <button>s in <select> with appearance:base-select have the behavior which opens the listbox by default without the need for type=popover. If there are multiple buttons and any of them have type=popover, then only those one(s) will have the opening behavior. This was resolved in openui here: openui/open-ui#939 (comment) Bug: 40146374 Change-Id: I689e3f35f292586f83070a5443e382eedae1e555
- Loading branch information
1 parent
f79be6c
commit 73755b5
Showing
7 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...orms/the-select-element/stylable-select/select-button-type-popover-default.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!DOCTYPE html> | ||
<link rel=author href="mailto:jarhar@chromium.org"> | ||
<link rel=help href="https://github.com/whatwg/html/issues/9799"> | ||
<link rel=help href="https://github.com/openui/open-ui/issues/939#issuecomment-1910837275"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
|
||
<style> | ||
select { | ||
appearance: base-select; | ||
} | ||
</style> | ||
|
||
<select id=select-one> | ||
<button class=one>button one</button> | ||
<button class=two>button two</button> | ||
<option>one</option> | ||
<option>two</option> | ||
</select> | ||
|
||
<select id=select-two> | ||
<button class=one>button one</button> | ||
<button class=two type=popover>button two</button> | ||
<option>one</option> | ||
<option>two</option> | ||
</select> | ||
|
||
<select id=select-three> | ||
<button class=one type=popover>button one</button> | ||
<button class=two type=popover>button two</button> | ||
<option>one</option> | ||
<option>two</option> | ||
</select> | ||
|
||
<script> | ||
promise_test(async () => { | ||
const select = document.getElementById('select-one'); | ||
const b1 = select.querySelector('.one'); | ||
const b2 = select.querySelector('.two'); | ||
|
||
b1.click(); | ||
assert_true(select.matches(':open'), | ||
'Clicking b1 should open the listbox.'); | ||
b1.click(); | ||
assert_false(select.matches(':open'), | ||
'Clicking b1 again should close the listbox.'); | ||
|
||
b2.click(); | ||
assert_true(select.matches(':open'), | ||
'Clicking b2 should open the listbox.'); | ||
b2.click(); | ||
assert_false(select.matches(':open'), | ||
'Clicking b2 again should close the listbox.'); | ||
}, 'If there are two buttons without type=popover, then they should both open the listbox.'); | ||
|
||
promise_test(async () => { | ||
const select = document.getElementById('select-two'); | ||
const b1 = select.querySelector('.one'); | ||
const b2 = select.querySelector('.two'); | ||
|
||
b1.click(); | ||
assert_false(select.matches(':open'), | ||
'Clicking b1 should not open the listbox.'); | ||
|
||
b2.click(); | ||
assert_true(select.matches(':open'), | ||
'Clicking b2 should open the listbox.'); | ||
b2.click(); | ||
assert_false(select.matches(':open'), | ||
'Clicking b2 again should close the listbox.'); | ||
}, 'If there are two buttons and one has type=popover, then only the type=popover one should open the listbox.'); | ||
|
||
promise_test(async () => { | ||
const select = document.getElementById('select-three'); | ||
const b1 = select.querySelector('.one'); | ||
const b2 = select.querySelector('.two'); | ||
|
||
b1.click(); | ||
assert_true(select.matches(':open'), | ||
'Clicking b1 should open the listbox.'); | ||
b1.click(); | ||
assert_false(select.matches(':open'), | ||
'Clicking b1 again should close the listbox.'); | ||
|
||
b2.click(); | ||
assert_true(select.matches(':open'), | ||
'Clicking b2 should open the listbox.'); | ||
b2.click(); | ||
assert_false(select.matches(':open'), | ||
'Clicking b2 again should close the listbox.'); | ||
}, 'If there are two buttons and they both have type=popover, then they should both open the listbox.'); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters