fix: improve click handling for injected components in ThreeDotsMenu#538
fix: improve click handling for injected components in ThreeDotsMenu#538
Conversation
There was a problem hiding this comment.
Pull request overview
Improves how ThreeDotsMenu forwards clicks to injected dropdown components by attempting to trigger either an exposed click() method or the component’s root element click.
Changes:
- Updated
injectedComponentClickto call an injected component’sclick()method when present. - Added a fallback to call
componentRef.$el.click()when noclick()method is exposed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (typeof (componentRef as any).click === 'function') { | ||
| (componentRef as any).click(); | ||
| } else if (componentRef.$el && typeof componentRef.$el.click === 'function') { | ||
| componentRef.$el.click(); | ||
| } |
There was a problem hiding this comment.
Calling componentRef.$el.click() from within the parent @click handler can synchronously dispatch a new click event that bubbles back to this same handler, potentially causing recursive re-entry (and double-triggering actions). Consider adding a re-entrancy guard (e.g., ignore non-user-triggered events via event.isTrusted / a local flag) or dispatch a non-bubbling event / trigger a more direct component method so the synthetic click doesn’t re-invoke injectedComponentClick.
No description provided.