Skip to content

Commit 2549bf9

Browse files
committed
add click event handlers to Example 3
1 parent bcb35a8 commit 2549bf9

1 file changed

Lines changed: 48 additions & 7 deletions

File tree

ex2.html

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,22 @@ <h3 id="menu-button-heading">Example 2: Menu Button</h3>
167167
<section aria-labelledby="broken-content-models-heading">
168168
<h2 id="broken-content-models-heading">Violated Content Models</h2>
169169
<p>
170-
When the author breaks the content model, Blink switches the menulist or menubar element, whichever contains the violation, to a dialog role. We also switch keyboard navigation from arrow keys back to the Tab key. But, does this actually work?? Can screenreader users access all the content in "dialog mode"? How is keyboard navigation?
170+
When the author breaks the content model, Blink switches the menulist or
171+
menubar element, whichever contains the violation, to a dialog role. We
172+
also switch keyboard navigation from arrow keys back to the Tab key. But,
173+
does this actually work?? Can screenreader users access all the content in
174+
"dialog mode"? How is keyboard navigation?
171175
</p>
172176
<section aria-labelledby="basic-broken">
173177
<h3 id="basic-broken">Example 3: Bookmarks menubar</h3>
174178
<p>
175-
This is a menubar with a single menuitem, Bookmarks. Activating Bookmarks shows four items, with a hr separator between the last two. The presence of a button puts us in dialog mode, which in this case means the menulist has a role of dialog instead of a role of menu. The items (activating does nothing):
179+
This is a menubar with a single menuitem, Bookmarks. Activating Bookmarks
180+
shows four items, with a hr separator between the last two. The presence
181+
of a button puts us in dialog mode, which in this case means the menulist
182+
has a role of dialog instead of a role of menu. The items:
176183
<ol>
177-
<li>Add Bookmark</li>
178-
<li>A button(!)</li>
184+
<li>Add Bookmark -- this menuitem has a click handler that shows an alert</li>
185+
<li>A button(!) -- both the button and the button menuitem have click handlers that show alerts</li>
179186
<li>Delete Bookmark</li>
180187
<li>Open Bookmark Manager</li>
181188
</ol>
@@ -184,8 +191,8 @@ <h3 id="basic-broken">Example 3: Bookmarks menubar</h3>
184191
<submenu>
185192
<menuitem>Bookmarks</menuitem>
186193
<menulist>
187-
<menuitem>Add Bookmark</menuitem>
188-
<menuitem><button>Some button</button></menuitem>
194+
<menuitem id="add-bookmark-item">Add Bookmark</menuitem>
195+
<menuitem id="button-menuitem"><button id="inner-button">Some button</button></menuitem>
189196
<menuitem>Delete Bookmark</menuitem>
190197
<hr />
191198
<menuitem>Open Bookmark Manager</menuitem>
@@ -194,10 +201,44 @@ <h3 id="basic-broken">Example 3: Bookmarks menubar</h3>
194201
</menubar>
195202
</section>
196203

204+
<script>
205+
document.addEventListener("DOMContentLoaded", () => {
206+
const addBookmarkItem = document.getElementById("add-bookmark-item");
207+
if (!addBookmarkItem) {
208+
throw new Error("Critical Test Failure: The 'add-bookmark-item' element is missing from the DOM.");
209+
}
210+
addBookmarkItem.addEventListener("click", () => {
211+
alert("Bookmark added!");
212+
});
213+
214+
const buttonMenuitem = document.getElementById("button-menuitem");
215+
if (!buttonMenuitem) {
216+
throw new Error("Critical Test Failure: The 'button-menuitem' element is missing from the DOM.");
217+
}
218+
buttonMenuitem.addEventListener("click", () => {
219+
alert("Button menuitem clicked!");
220+
});
221+
222+
const innerButton = document.getElementById("inner-button");
223+
if (!innerButton) {
224+
throw new Error("Critical Test Failure: The 'inner-button' element is missing from the DOM.");
225+
}
226+
innerButton.addEventListener("click", (e) => {
227+
alert("Inner button clicked!");
228+
});
229+
});
230+
</script>
231+
197232
<section aria-labelledby="complex-broken">
198233
<h3 id="complex-broken">Example 4: Broken File menu</h3>
199234
<p>
200-
This is the original File, Edit.. etc menu. Except this time there's a link at File > New. Selecting File > Open Recent's submenu seems difficult with our current implementation. You have to Tab from new to Open Recent, then activate with enter or space, then resume arrow key navigation. Left arrow from Open Recent's submenu moves focus back onto Open Recent, but you can't use right arrow to go back into the submenu. Yeah, seems not great.
235+
This is the original File, Edit.. etc menu. Except this time there's a
236+
link at File &gt; New. Selecting File &gt; Open Recent's submenu seems
237+
difficult with our current implementation. You have to Tab from new to
238+
Open Recent, then activate with enter or space, then resume arrow key
239+
navigation. Left arrow from Open Recent's submenu moves focus back onto
240+
Open Recent, but you can't use right arrow to go back into the submenu.
241+
Yeah, seems not great.
201242
</p>
202243
<menubar>
203244
<!-- File Menu -->

0 commit comments

Comments
 (0)