Listen to Tab's onMouseDown event outside the component #2435
-
Hello, I've implemented a Tabs component using I noticed that somewhere in my application there is a hook that listens to I noticed that the Browsing through the code I noticed this snippet react-spectrum/packages/@react-aria/interactions/src/usePress.ts Lines 333 to 348 in 2a0f664 So my understanding, is that this event will never bubble up. I might be completely wrong, so feel free to correct me. Is there a way I can make this interaction work? Having my Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I have this workaround const onClick = (event: React.MouseEvent<HTMLElement>) => {
if (typeof tabProps.onClick === 'function') {
tabProps.onClick(event);
const clonedNativeEvent = new Event('mousedown', event.nativeEvent);
event.target.dispatchEvent(clonedNativeEvent);
}
};
const nextTabProps = {...tabProps, onClick}; This is very suboptimal, and I understand that the consumer should normally use either an overlay to capture the clicks, or proper focus management. |
Beta Was this translation helpful? Give feedback.
I have this workaround
This is very suboptimal, and I understand that the consumer should normally use either an overlay to capture the clicks, or proper focus management.