Skip to content

Commit a016867

Browse files
committed
Add example of autofocus
1 parent 91ca4de commit a016867

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

examples/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
</style>
2525
</head>
2626
<body>
27+
<h1>Base examples</h1>
28+
2729
<details>
2830
<summary>Best robot: <span data-menu-button>Unknown</span></summary>
2931
<details-menu>
@@ -60,6 +62,20 @@
6062
</details-menu>
6163
</details>
6264

65+
<h1>Autofocus example</h1>
66+
<p><code>summary</code> may have <code>autofocus</code> so it's the initially focused element in the page.</p>
67+
<p>Then any focusable element inside the popup can declare autofocus too, so it gets focus when the popup is opened.</p>
68+
69+
<details>
70+
<summary data-menu-button autofocus>Autofocus picker</summary>
71+
<details-menu>
72+
<input type="text" placeholder="Autofocus wannabe filter" autofocus />
73+
<button type="submit" name="robot" value="Hubot" role="menuitemradio" data-menu-button-text>Hubot</button>
74+
<button type="submit" name="robot" value="Bender" role="menuitemradio" data-menu-button-text>Bender</button>
75+
<button type="submit" name="robot" value="BB-8" role="menuitemradio" data-menu-button-text>BB-8</button>
76+
</details-menu>
77+
</details>
78+
6379
<script type="text/javascript">
6480
document.addEventListener('details-menu-selected', e => console.log(e))
6581
</script>

0 commit comments

Comments
 (0)