-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Refactored ShowSpace view: rendering name field dynamically * Extract NewFolder view from ShowSpace view to separate templ file * Added autofocus to new folder form (used when invalid) #134 * Refactored EditFolder view: rendering name field dynamically * Added hotkey to "Make new folder" button #134 * Fix for hotkeys in Firefox/Safari #134
- Loading branch information
1 parent
276f034
commit 0cb01ec
Showing
17 changed files
with
476 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import htmx from "htmx.org"; | ||
|
||
export default function (rootEl) { | ||
const hotkeyElements = Array.from(rootEl.querySelectorAll("[data-hotkey]")); | ||
if (hotkeyElements.length) { | ||
htmx.on("keyup", (evt) => { | ||
const el = hotkeyElements.find((el) => | ||
el.matches(`[data-hotkey="${evt.key}"]`), | ||
); | ||
|
||
// Make sure the "hotkey-element" is still in the DOM | ||
// and the triggering element is not a form field | ||
if (el && el.isConnected && !isFormField(evt.target)) { | ||
el.dispatchEvent(new MouseEvent("click")); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function isFormField(el) { | ||
return el.matches( | ||
"input:not([type=button]):not([type=reset]):not([type=submit]):not([type=image]):not([type=file]), textarea, select", | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.