Skip to content

Commit e5d79a1

Browse files
committed
Test focus change
1 parent eda2254 commit e5d79a1

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

assets/html/index.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@
211211
<span id="dialog-content">You got all six questions correct. Great work!</span>
212212
</div>
213213
<div style="width: 100%">
214-
<button type="submit" autofocus>Close</button>
214+
<!-- <button id="modal-close-button" autofocus tabindex="0">Close</button> -->
215+
<button id="modal-close-button" type="submit" autofocus>Close</button>
215216
</div>
216217
</form>
217218
</dialog>
@@ -225,6 +226,37 @@ <h1 id="main-heading">Pop Quiz</h1>
225226
<div id="question-footer"></div>
226227
</div>
227228
<script>
229+
function setVoiceOverFocus(element) {
230+
var focusInterval = 1; // ms, time between function calls
231+
var focusTotalRepetitions = 100; // number of repetitions
232+
233+
element.setAttribute('tabindex', '0');
234+
element.blur();
235+
236+
var focusRepetitions = 0;
237+
var interval = window.setInterval(function() {
238+
element.focus();
239+
focusRepetitions++;
240+
if (focusRepetitions >= focusTotalRepetitions) {
241+
window.clearInterval(interval);
242+
}
243+
}, focusInterval);
244+
}
245+
246+
document.getElementById("modal-close-button").addEventListener("click", () => {
247+
document.getElementById("show-score-modal").close();
248+
// setVoiceOverFocus(document.getElementById("show-score-button"))
249+
// let iterations = 0;
250+
// const showScoreButton = document.getElementById("show-score-button");
251+
// console.log(showScoreButton);
252+
// while (true) {
253+
// console.log(document.activeElement)
254+
// showScoreButton.focus();
255+
// if (iterations >= 500)
256+
// break;
257+
// iterations += 1;
258+
// }
259+
});
228260
const nextQuestionHtml =`
229261
<button id="next-question-button">Next question <span aria-hidden="true">➡️ </span></button>
230262
`

0 commit comments

Comments
 (0)