Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(Popup): fix click outside when trigger is not defined#2202

Merged
layershifter merged 2 commits intomasterfrom
fix/popup-without-trigger
Jan 3, 2020
Merged

fix(Popup): fix click outside when trigger is not defined#2202
layershifter merged 2 commits intomasterfrom
fix/popup-without-trigger

Conversation

@layershifter
Copy link
Member

@layershifter layershifter commented Jan 2, 2020

This PR fixes a cases when clicks outside of Popup were not properly handled in controlled mode without trigger prop.

@DustyTheBot
Copy link
Collaborator

DustyTheBot commented Jan 2, 2020

Perf comparision

Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
Button.Fluent 1.15 0.13 8.85:1 5000 5759
Checkbox.Fluent 1.34 0.24 5.58:1 5000 6685
Icon.Fluent 0.25 0.04 6.25:1 5000 1238
Slider.Fluent 1.85 0.26 7.12:1 5000 9226

Generated by 🚫 dangerJS

@layershifter layershifter added 🚀 ready for review 🧰 fix Introduces fix for broken behavior. labels Jan 2, 2020
const isInsideTriggerElement =
this.triggerRef.current &&
!doesNodeContainClick(this.triggerRef.current, e, this.context.target)
doesNodeContainClick(this.triggerRef.current, e, this.context.target)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just an observation, this is not exactlly the negated condition. Is that expected? The negated would look like this:

  const isInsideTriggerElement =
      !this.triggerRef.current || doesNodeContainClick(this.triggerRef.current, e, this.context.target)

Just mentioning in case if this was done only for readability

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, it's expected as to check that click was inside we need to have a trigger element and click should inside of it. And if click was isOutsidePopupElement and !isInsideTriggerElement we can close Popup. But agree, this conditions are a bit crazy.

@layershifter layershifter merged commit 8939472 into master Jan 3, 2020
@layershifter layershifter deleted the fix/popup-without-trigger branch January 3, 2020 09:17
delprzemo pushed a commit to delprzemo/fluent-ui-react that referenced this pull request Jan 5, 2020
delprzemo pushed a commit to delprzemo/fluent-ui-react that referenced this pull request Jan 31, 2020
jurokapsiar pushed a commit that referenced this pull request Feb 9, 2020
#2208)

* fix(AlertBehavior) add missing aria-describedby to AlertBehavior when type is different than warning/danger #2197

* Fix tests for alertBehavior aria-describedby attribute

* Remove duplication of aria-describedby assignment in alert dismiss behavior

* Fix test for aria-describedby in Alert behavior

* Update changelog for #2202

* Fix changelog log for #2208 PR

* Set proper PR id in CHANGELOG.md

* Move CHANGELOG log into unreleased section
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🧰 fix Introduces fix for broken behavior. 🚀 ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants