turbo_boost-elements 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/builds/@turbo-boost/elements.js +5 -5
- data/app/assets/builds/@turbo-boost/elements.js.map +3 -3
- data/app/javascript/elements/toggle_elements/target_element/focus.js +2 -2
- data/app/javascript/elements/toggle_elements/trigger_element/index.js +4 -0
- data/lib/turbo_boost/elements/version.rb +1 -1
- metadata +1 -1
@@ -45,8 +45,8 @@ function focusTrixEditorElement (element) {
|
|
45
45
|
|
46
46
|
function shouldEnhanceFocus (element) {
|
47
47
|
if (!element.tagName.match(/^input|textarea|trix-editor$/i)) return false
|
48
|
-
const toggleTargetElement = element.closest('turbo-boost-toggle-target')
|
49
|
-
return toggleTargetElement
|
48
|
+
const toggleTargetElement = element.closest('turbo-boost-toggle-target') || {}
|
49
|
+
return !!toggleTargetElement.focusElement
|
50
50
|
}
|
51
51
|
|
52
52
|
function enhanceFocus (element) {
|
@@ -68,9 +68,13 @@ export default class ToggleTriggerElement extends ToggleElement {
|
|
68
68
|
// TODO: implement cache - this.targetElement.renderCachedHTML()
|
69
69
|
}
|
70
70
|
|
71
|
+
// runs before an invoke turbo stream is executed
|
71
72
|
onBeforeInvoke (event) {
|
73
|
+
// return early if we're not the element responsible for this invoke
|
72
74
|
if (event.detail.method !== 'morph') return
|
73
75
|
if (event.target.id !== this.morphs) return
|
76
|
+
const selector = `turbo-boost-toggle-target[aria-labeledby="${this.id}"]`
|
77
|
+
if (!event.target.querySelector(selector)) return
|
74
78
|
|
75
79
|
// ensure the busy element is shown long enough for a good user experience
|
76
80
|
// we accomplish this by modifying the event.detail with invoke instructions i.e. { delay }
|