Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[popover2] fix(Popover2): get correct click target in shadow DOM #5909

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

kutensky
Copy link
Contributor

@kutensky kutensky commented Jan 31, 2023

Fixes #5908

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Get the actual click target. The same way it was done in "overlay.tsx" in function "handleDocumentClick"

@@ -685,7 +685,7 @@ export class Popover2<T extends DefaultPopover2TargetHTMLProps> extends Abstract
return;
}

const eventTarget = e.target as HTMLElement;
const eventTarget = (e.composed ? e.composedPath()[0] : e.target) as HTMLElement;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this approach seems reasonable, but I think you'll need to access e.nativeEvent.composedPath (docs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense according to e is "React.SyntheticEvent". But actually the caller of this function passes native event instead of React.SyntheticEvent.
I guess in that case I can check that "e" has "nativeEvent" and use it, otherwise use "e"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I updated the code

@adidahiya adidahiya changed the title [popover2] fix(popover2): get actual click target [popover2] fix(Popover2): get correct click target in shadow DOM Jan 31, 2023
@adidahiya
Copy link
Contributor

thanks @kutensky

@adidahiya adidahiya merged commit 61a0ef8 into palantir:develop Feb 1, 2023
@kutensky
Copy link
Contributor Author

kutensky commented Feb 1, 2023

thanks @kutensky

Thank you for such a quick response. That fix will help to close a bug in our application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking Popover button reopens it when in Shadow DOM
2 participants