turbo_boost-elements 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 && toggleTargetElement.focusSelector
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 }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TurboBoost
4
4
  module Elements
5
- VERSION = "0.0.11"
5
+ VERSION = "0.0.12"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_boost-elements
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Hopkins (hopsoft)