From 80cc46667de5062e097f5cd6e51e74c40e5bb063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 12 Apr 2022 02:17:34 +0200 Subject: Fix edit popups not auto opening. Depending an the exact text of an translatable string seems like a bad idea. --- module/calp/html/vcomponent.scm | 5 ++++- static/components/popup-element.ts | 2 +- static/components/tab-group-element.ts | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm index 91db44e6..c9765f63 100644 --- a/module/calp/html/vcomponent.scm +++ b/module/calp/html/vcomponent.scm @@ -618,7 +618,10 @@ (class "vevent"))) (vevent-edit - (@ (data-label "🖊") (data-title ,(_ "Edit")))) + (@ (data-label "🖊") + (data-title ,(_ "Edit")) + ;; Used by JavaScript to target this tab + (data-originaltitle "Edit"))) ;; (vevent-edit-rrule ;; (@ (data-label "↺") (data-title "Upprepningar"))) diff --git a/static/components/popup-element.ts b/static/components/popup-element.ts index 35c966ac..3300f885 100644 --- a/static/components/popup-element.ts +++ b/static/components/popup-element.ts @@ -151,7 +151,7 @@ function setup_popup_element(ev: VEvent): PopupElement { ev.register(popup); /* TODO propper way to find popup container */ (document.querySelector('.days') as Element).appendChild(popup); - let tabBtn = popup.querySelector('[role="tab"][title="Redigera"]') as HTMLButtonElement + let tabBtn = popup.querySelector('[role="tab"][data-originaltitle="Edit"]') as HTMLButtonElement tabBtn.click() let tab = document.getElementById(tabBtn.getAttribute('aria-controls')!)! let input = tab.querySelector('input[name="summary"]') as HTMLInputElement diff --git a/static/components/tab-group-element.ts b/static/components/tab-group-element.ts index 05cac7d2..8a65964d 100644 --- a/static/components/tab-group-element.ts +++ b/static/components/tab-group-element.ts @@ -87,6 +87,11 @@ class TabGroupElement extends ComponentVEvent { but still defaut to '?' if no text is found */ label = label || child.dataset.label || (child.textContent + '?')[0]; title = title || child.dataset.title || ''; + let extra_attributes = {}; + /* Used to target a tab by name */ + if (child.dataset.originaltitle) { + extra_attributes = { 'data-originaltitle': child.dataset.originaltitle } + } let tab_id = gensym('tab_content_'); let label_id = gensym('tab_label_'); @@ -100,6 +105,7 @@ class TabGroupElement extends ComponentVEvent { title: title, 'aria-selected': false, 'aria-controls': tab_id, + ... extra_attributes, }) let tabContainer = makeElement('article', {}, { -- cgit v1.2.3