Skip to content

Commit 6c5c99e

Browse files
committed
Add test for the fixed scenario.
1 parent a016867 commit 6c5c99e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,22 @@ describe('details-menu element', function () {
601601

602602
assert.equal(input, document.activeElement, 'toggle open focuses on [autofocus]')
603603
})
604+
605+
it('summary autofocus should not impact with inner autofocus element', function () {
606+
const details = document.querySelector('details')
607+
const summary = details.querySelector('summary')
608+
const input = details.querySelector('input')
609+
610+
// Summary is the initial element of the entire page, while input is the initial element in the popup
611+
summary.setAttribute('autofocus', '')
612+
613+
summary.focus()
614+
details.open = true
615+
summary.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter', bubbles: true}))
616+
details.dispatchEvent(new CustomEvent('toggle'))
617+
618+
assert.equal(document.activeElement, input, 'toggle open focuses on [autofocus]')
619+
})
604620
})
605621

606622
describe('closing the menu', function () {

0 commit comments

Comments
 (0)