From 44116eba5a5613323b17be5460ff675caa78cebc Mon Sep 17 00:00:00 2001 From: juanatsap Date: Tue, 2 Dec 2025 17:55:45 +0000 Subject: [PATCH] refactor: use hyperscript event filtering and destructuring - Use event filtering [key is 'Enter' or key is ' '] on PDF modal cards - Remove handlePdfCardKey helper function (now inline) - Use event destructuring on keydown(key, target, ctrlKey, metaKey, altKey) - Cleaner, more idiomatic hyperscript patterns --- static/hyperscript/pdf-modal._hs | 10 ---------- templates/index.html | 15 +++++++-------- templates/partials/modals/pdf-modal.html | 6 +++--- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/static/hyperscript/pdf-modal._hs b/static/hyperscript/pdf-modal._hs index a148d5f..d067ec2 100644 --- a/static/hyperscript/pdf-modal._hs +++ b/static/hyperscript/pdf-modal._hs @@ -33,13 +33,3 @@ def selectPdfCard(card) set window.selectedPdfFormat to card's @data-cv-format end --- ============================================================================== --- PDF CARD KEYDOWN HANDLER --- ============================================================================== --- Handles keyboard navigation for PDF cards (Enter/Space to select) -def handlePdfCardKey(card, evt) - if evt.key is 'Enter' or evt.key is ' ' - call evt.preventDefault() - call selectPdfCard(card) - end -end diff --git a/templates/index.html b/templates/index.html index b68743c..2a543de 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,16 +4,15 @@ diff --git a/templates/partials/modals/pdf-modal.html b/templates/partials/modals/pdf-modal.html index 0b6984c..fa199e2 100644 --- a/templates/partials/modals/pdf-modal.html +++ b/templates/partials/modals/pdf-modal.html @@ -45,7 +45,7 @@ aria-label="{{.UI.PdfModal.ShortCv.AriaLabel}}" tabindex="0" _="on click call selectPdfCard(me) - on keydown call handlePdfCardKey(me, event)"> + on keydown[key is 'Enter' or key is ' '] halt the event then call selectPdfCard(me)">
@@ -80,7 +80,7 @@ aria-label="{{.UI.PdfModal.DefaultCv.AriaLabel}}" tabindex="0" _="on click call selectPdfCard(me) - on keydown call handlePdfCardKey(me, event)"> + on keydown[key is 'Enter' or key is ' '] halt the event then call selectPdfCard(me)">
@@ -123,7 +123,7 @@ aria-label="{{.UI.PdfModal.ExtendedCv.AriaLabel}}" tabindex="0" _="on click call selectPdfCard(me) - on keydown call handlePdfCardKey(me, event)"> + on keydown[key is 'Enter' or key is ' '] halt the event then call selectPdfCard(me)">