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

[Bug]: The Callout onDismiss handler is not triggered when clicking a different iframe #26927

Closed
2 tasks done
MemMaoxin opened this issue Feb 21, 2023 · 3 comments
Closed
2 tasks done
Labels
Fluent UI react (v8) Issues about @fluentui/react (v8) Resolution: Duplicate

Comments

@MemMaoxin
Copy link

MemMaoxin commented Feb 21, 2023

Library

React / v8 (@fluentui/react)

System Info

Package version(s): "@fluentui/[email protected]"
Browser and OS versions: Microsoft edge/Version 110.0.1587.49

Are you reporting Accessibility issue?

None

Reproduction

https://codepen.io/xinxinZZZ/pen/gOdPqQN?editors=1111

Bug Description

Steps:

  1. Open codepen: https://codepen.io/xinxinZZZ/pen/gOdPqQN?editors=1111
  2. Press the show callout button. A callout should appear.
  3. Click the square box (iframe). Notice that the callout does not disappear and onDismiss handler is not called.

Actual Behavior

When clicking inside an iframe (but outside of the callout), the callout is not dismissed.

Expected Behavior

When clicking outside the callout, the onDismiss handler should be triggered, and the callout should disappear.

Possible Cause

I think the reason is the method "dismissOnTargetWindowBlur" handle the evt incorrectly in https://github.com/microsoft/fluentui/blame/master/packages/react/src/components/Callout/CalloutContent.base.tsx.
image

When we click inside an iframe, the result of "targetWindow.document.hasFocus()" is true, so the onDismiss method in 348 lines wouldn't be executed.
So we should add this logic as follows:
if ( ((preventDismissOnEvent && !preventDismissOnEvent(ev)) || (!preventDismissOnEvent && !preventDismissOnLostFocus)) && (!targetWindow?.document.hasFocus() || ev.target === targetRef.current) && ev.relatedTarget === null ) { onDismiss?.(ev); }

Logs

No response

Requested priority

Blocking

Products/sites affected

Updates App and Approvals App in Teams

Are you willing to submit a PR to fix?

yes

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@github-actions github-actions bot added the Fluent UI react (v8) Issues about @fluentui/react (v8) label Feb 21, 2023
@micahgodbolt
Copy link
Member

Duplicate of #22133

@MemMaoxin
Copy link
Author

Hi @micahgodbolt, I have careted a pr to solve this problem: #26930. Please help review, thanks!

@msft-fluent-ui-bot
Copy link
Collaborator

Because this issue is marked as a duplicate and has not had activity for over 3 days, we're closing this issue for house-keeping purposes. Please refer to the issue that this issue was duplicated to for the purposes of tracking progress. Thank you.

@microsoft microsoft locked as resolved and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fluent UI react (v8) Issues about @fluentui/react (v8) Resolution: Duplicate
Projects
None yet
Development

No branches or pull requests

3 participants