Skip to content

Commit

Permalink
Allow navigation when e.g. details.notes is focused
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaVerou committed Jun 26, 2024
1 parent 20b5ec3 commit a69b773
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/inspire.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ let _ = {
// This works better than commenting, which cannot be
ignore: ".inspire-remove, .inspire-comment",

// Arrow keys inside these elements will not trigger navigation
editableElements: "input, textarea, select, button, [contenteditable]",

ready: util.defer(),
slideshowCreated: util.defer(),
importsLoaded: imports.loaded,
Expand Down Expand Up @@ -238,7 +241,7 @@ let _ = {
(Shift instead of Ctrl works too)
*/
"keyup": evt => {
if (!document.activeElement.matches("input, textarea, select, button")) {
if (!document.activeElement.matches(_.editableElements)) {
let letter = evt.key.toUpperCase();

if (letter === "G" && (evt.ctrlKey || evt.shiftKey) && !evt.altKey) {
Expand All @@ -261,7 +264,7 @@ let _ = {
(Shift instead of Ctrl works too)
*/
"keydown": evt => {
if (evt.altKey || evt.target.contains(_.currentSlide)) {
if (evt.altKey || evt.target.contains(_.currentSlide) || !evt.target.matches(_.editableElements)) {
if (evt.keyCode >= 32 && evt.keyCode <= 40) {
evt.preventDefault();
}
Expand Down Expand Up @@ -343,7 +346,7 @@ let _ = {
}
},

previous(hard) {
previous (hard) {
if (!hard && _.item > 0) {
_.previousItem();
}
Expand Down

0 comments on commit a69b773

Please sign in to comment.