fix: fall back to DOM traversal in targetFromEvent when composedPath is empty
CI / Build & Quality Checks (push) Successful in 10m44s
Trigger Desktop Build / trigger (push) Successful in 22s

composedPath() returns an empty array once the native event is no longer
dispatching. In React 19, events from a portal-within-portal (EmojiBoard
inside #portalContainer, which already hosts the Settings Overlay) can reach
the synthetic event handler after the native dispatch window closes.

The fallback walks up from evt.target so handleGroupItemClick still finds
the emoji button and calls onEmojiSelect — fixing emoji selection in the
status-message editor in Settings > Account > Profile.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 21:31:07 -04:00
parent 362f4943d4
commit 6a57c13c56
+11 -1
View File
@@ -1,6 +1,16 @@
export const targetFromEvent = (evt: Event, selector: string): Element | undefined => {
const targets = evt.composedPath() as Element[];
return targets.find((target) => target.matches?.(selector));
if (targets.length > 0) {
return targets.find((target) => target.matches?.(selector));
}
// composedPath() is empty when the event is no longer dispatching (e.g. inside a
// portal-within-portal in React 19). Walk up the DOM from evt.target instead.
let el = evt.target instanceof Element ? evt.target : null;
while (el) {
if (el.matches(selector)) return el;
el = el.parentElement;
}
return undefined;
};
export const editableActiveElement = (): boolean =>