Skip to content

Conversation

@layershifter
Copy link
Member

@layershifter layershifter commented Feb 22, 2022

New Behavior

This PR adds new Popper.js modifier called isIntersectingModifier to usePopper() hook in Fluent UI N*.

This modifier is based on the ask from a partner team. Currently we have already used hide modifier that adds following DOM attributes based on state:

  • data-popper-reference-hidden: This attribute gets applied to the popper when the reference element is fully clipped and hidden from view, which causes the popper to appear to be attached to nothing.
  • data-popper-escaped: This attribute gets applied when the popper escapes the reference element's boundary (and so it appears detached).

The problem that there is no state when a popover intersects boundaries:
image

The partner team wants to hide popovers once they reach boundaries. This PR adds new modifier that adds [data-popper-is-intersecting] once such scenario happens.

The data attribute can be used to apply styling:

<Box
  styles={{
    "[data-popper-is-intersecting]": { visibility: "hidden" }
  }}
/>

New visual tests were added to cover this scenario.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 22, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3bbff27:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@size-auditor
Copy link

size-auditor bot commented Feb 22, 2022

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-northstar-Datepicker 201.343 kB 201.716 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-Dropdown 211.17 kB 211.543 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-SplitButton 192.459 kB 192.832 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-Popup 146.238 kB 146.611 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-MenuButton 176.191 kB 176.564 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-Menu 141.172 kB 141.545 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-Tooltip 120.024 kB 120.397 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-Toolbar 188.672 kB 189.045 kB ExceedsBaseline     373 bytes
office-ui-fabric-react fluentui-react-northstar-Chat 165.512 kB 165.885 kB ExceedsBaseline     373 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: f3017f1596086ed5af22318122baebd2ca620c41 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 22, 2022

📊 Bundle size report

🤖 This report was generated against f3017f1596086ed5af22318122baebd2ca620c41

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 22, 2022

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 702 747 5000
BaseButton mount 778 723 5000
Breadcrumb mount 2153 2052 1000
ButtonNext mount 424 381 5000
Checkbox mount 1321 1243 5000
CheckboxBase mount 1046 1131 5000
ChoiceGroup mount 3815 3749 5000
ComboBox mount 884 824 1000
CommandBar mount 8488 8639 1000
ContextualMenu mount 6970 6838 1000
DefaultButton mount 964 921 5000
DetailsRow mount 2920 3254 5000
DetailsRowFast mount 3201 3111 5000
DetailsRowNoStyles mount 3025 3116 5000
Dialog mount 1882 1890 1000
DocumentCardTitle mount 154 138 1000
Dropdown mount 3524 2743 5000
FluentProviderNext mount 1658 1629 5000
FluentProviderWithTheme mount 151 146 10
FluentProviderWithTheme virtual-rerender 96 95 10
FluentProviderWithTheme virtual-rerender-with-unmount 167 185 10
FocusTrapZone mount 1470 1456 5000
FocusZone mount 1526 1546 5000
IconButton mount 1473 1385 5000
Label mount 323 333 5000
Layer mount 2523 2350 5000
Link mount 386 420 5000
MakeStyles mount 1309 1421 50000
MenuButton mount 1278 1254 5000
MessageBar mount 1700 1616 5000
Nav mount 2627 2589 1000
OverflowSet mount 950 995 5000
Panel mount 1849 1775 1000
Persona mount 711 687 1000
Pivot mount 1164 1274 1000
PrimaryButton mount 1130 1134 5000
Rating mount 6051 6204 5000
SearchBox mount 1071 1183 5000
Shimmer mount 2182 2165 5000
Slider mount 1696 1586 5000
SpinButton mount 3973 4360 5000
Spinner mount 398 390 5000
SplitButton mount 2501 2731 5000
Stack mount 473 429 5000
StackWithIntrinsicChildren mount 1856 1834 5000
StackWithTextChildren mount 4372 4285 5000
SwatchColorPicker mount 9196 9350 5000
TagPicker mount 2027 2221 5000
TeachingBubble mount 12917 19360 5000
Text mount 351 350 5000
TextField mount 1232 1156 5000
ThemeProvider mount 1040 971 5000
ThemeProvider virtual-rerender 1582 559 5000
ThemeProvider virtual-rerender-with-unmount 1454 3876 5000
Toggle mount 692 673 5000
buttonNative mount 123 137 5000

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AttachmentMinimalPerf.default 143 116 1.23:1
ChatWithPopoverPerf.default 342 291 1.18:1
FormMinimalPerf.default 359 306 1.17:1
MenuButtonMinimalPerf.default 1565 1345 1.16:1
BoxMinimalPerf.default 293 254 1.15:1
AlertMinimalPerf.default 234 208 1.13:1
HeaderMinimalPerf.default 313 277 1.13:1
LabelMinimalPerf.default 338 300 1.13:1
GridMinimalPerf.default 289 257 1.12:1
TextAreaMinimalPerf.default 436 394 1.11:1
TableManyItemsPerf.default 1615 1463 1.1:1
HeaderSlotsPerf.default 655 609 1.08:1
SkeletonMinimalPerf.default 290 268 1.08:1
DatepickerMinimalPerf.default 4505 4227 1.07:1
ListNestedPerf.default 476 443 1.07:1
EmbedMinimalPerf.default 3419 3216 1.06:1
RosterPerf.default 1029 967 1.06:1
PopupMinimalPerf.default 520 492 1.06:1
TextMinimalPerf.default 273 258 1.06:1
TreeWith60ListItems.default 149 140 1.06:1
ListCommonPerf.default 554 527 1.05:1
StatusMinimalPerf.default 589 566 1.04:1
DialogMinimalPerf.default 624 608 1.03:1
LoaderMinimalPerf.default 597 580 1.03:1
ButtonMinimalPerf.default 153 150 1.02:1
ButtonOverridesMissPerf.default 1334 1309 1.02:1
CheckboxMinimalPerf.default 2110 2076 1.02:1
AnimationMinimalPerf.default 414 408 1.01:1
AvatarMinimalPerf.default 149 148 1.01:1
DropdownManyItemsPerf.default 519 512 1.01:1
DropdownMinimalPerf.default 2308 2289 1.01:1
FlexMinimalPerf.default 259 256 1.01:1
RefMinimalPerf.default 213 211 1.01:1
SegmentMinimalPerf.default 305 303 1.01:1
ToolbarMinimalPerf.default 785 781 1.01:1
VideoMinimalPerf.default 484 477 1.01:1
InputMinimalPerf.default 1029 1028 1:1
MenuMinimalPerf.default 720 724 0.99:1
ReactionMinimalPerf.default 282 285 0.99:1
SliderMinimalPerf.default 1355 1365 0.99:1
IconMinimalPerf.default 510 515 0.99:1
CustomToolbarPrototype.default 3340 3359 0.99:1
ListMinimalPerf.default 433 443 0.98:1
LayoutMinimalPerf.default 272 279 0.97:1
ListWith60ListItems.default 532 555 0.96:1
SplitButtonMinimalPerf.default 3299 3423 0.96:1
ChatMinimalPerf.default 576 607 0.95:1
ItemLayoutMinimalPerf.default 924 969 0.95:1
ButtonSlotsPerf.default 403 429 0.94:1
ChatDuplicateMessagesPerf.default 238 256 0.93:1
PortalMinimalPerf.default 131 141 0.93:1
CardMinimalPerf.default 428 465 0.92:1
ProviderMergeThemesPerf.default 1337 1446 0.92:1
TooltipMinimalPerf.default 797 868 0.92:1
DividerMinimalPerf.default 274 301 0.91:1
RadioGroupMinimalPerf.default 350 383 0.91:1
AccordionMinimalPerf.default 121 134 0.9:1
CarouselMinimalPerf.default 370 411 0.9:1
TableMinimalPerf.default 311 351 0.89:1
TreeMinimalPerf.default 611 683 0.89:1
AttachmentSlotsPerf.default 818 929 0.88:1
ImageMinimalPerf.default 282 328 0.86:1
ProviderMinimalPerf.default 917 1813 0.51:1

@layershifter layershifter marked this pull request as ready for review February 22, 2022 13:02
};
state.attributes.popper = {
...state.attributes.popper,
'data-popper-is-intersecting': isIntersecting,
Copy link
Contributor

Choose a reason for hiding this comment

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

is it going to render data-popper-is-intersecting="false" ? or does the false not render anything at all ?

Copy link
Member Author

Choose a reason for hiding this comment

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

: false;

const modifiers: PopperJs.Options['modifiers'] = [
isIntersectingModifier,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want this on by default ? could it cause any issues with customers' tests ?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO yes. We have hide modifier enabled, this modifier acts in the same scope so it's reasonable to enable.

could it cause any issues with customers' tests ?

May be, but as it adds only data attribute I don't see problems with it.

Copy link
Contributor

@ling1726 ling1726 left a comment

Choose a reason for hiding this comment

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

Nice modifier, will you migrate it to v9 ? :)

@layershifter
Copy link
Member Author

Nice modifier, will you migrate it to v9 ? :)

Yes 👍 Do you want to this before or after #21828?

@ling1726
Copy link
Contributor

Nice modifier, will you migrate it to v9 ? :)

Yes 👍 Do you want to this before or after #21828?

before would be easier for me for sure 😛

But honestly the concepts in the modifier is very similar to Floating middleware. If you port it to v9 with vr-tests I don't mind ugprading it too

@layershifter layershifter merged commit e5cafd8 into microsoft:master Feb 23, 2022
@layershifter layershifter deleted the proto/popper-positioning branch February 23, 2022 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fluent UI react-northstar (v0) Work related to Fluent UI V0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants