Skip to content

Listen to Tab's onMouseDown event outside the component #2435

Answered by dimitrisnl
dimitrisnl asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@snowystinger
Comment options

@dimitrisnl
Comment options

@devongovett
Comment options

@dimitrisnl
Comment options

Answer selected by dimitrisnl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants