-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(Dialog): keep Dialog open when press click on content and release on overlay #22849
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
fix(Dialog): keep Dialog open when press click on content and release on overlay #22849
Conversation
|
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 d7a27df:
|
Asset size changes
Baseline commit: 8f40f25712a38b3b3121e7eb71623ce3d5a187e1 (build) |
📊 Bundle size report🤖 This report was generated against 8f40f25712a38b3b3121e7eb71623ce3d5a187e1 |
Perf Analysis (
|
| Scenario | Current PR Ticks | Baseline Ticks | Ratio |
|---|---|---|---|
| GridMinimalPerf.default | 350 | 314 | 1.11:1 |
| HeaderMinimalPerf.default | 377 | 340 | 1.11:1 |
| DropdownManyItemsPerf.default | 725 | 662 | 1.1:1 |
| SkeletonMinimalPerf.default | 357 | 326 | 1.1:1 |
| LayoutMinimalPerf.default | 382 | 349 | 1.09:1 |
| CardMinimalPerf.default | 586 | 546 | 1.07:1 |
| DividerMinimalPerf.default | 363 | 339 | 1.07:1 |
| ListMinimalPerf.default | 559 | 523 | 1.07:1 |
| RadioGroupMinimalPerf.default | 471 | 442 | 1.07:1 |
| AccordionMinimalPerf.default | 147 | 139 | 1.06:1 |
| AttachmentSlotsPerf.default | 1110 | 1056 | 1.05:1 |
| FormMinimalPerf.default | 426 | 407 | 1.05:1 |
| InputMinimalPerf.default | 1390 | 1325 | 1.05:1 |
| PopupMinimalPerf.default | 650 | 618 | 1.05:1 |
| BoxMinimalPerf.default | 343 | 330 | 1.04:1 |
| FlexMinimalPerf.default | 310 | 297 | 1.04:1 |
| MenuButtonMinimalPerf.default | 1737 | 1665 | 1.04:1 |
| IconMinimalPerf.default | 662 | 636 | 1.04:1 |
| DropdownMinimalPerf.default | 3209 | 3128 | 1.03:1 |
| TextAreaMinimalPerf.default | 488 | 474 | 1.03:1 |
| AttachmentMinimalPerf.default | 155 | 152 | 1.02:1 |
| ListCommonPerf.default | 658 | 647 | 1.02:1 |
| ListNestedPerf.default | 561 | 549 | 1.02:1 |
| StatusMinimalPerf.default | 710 | 697 | 1.02:1 |
| TableMinimalPerf.default | 398 | 391 | 1.02:1 |
| ButtonSlotsPerf.default | 590 | 585 | 1.01:1 |
| DialogMinimalPerf.default | 782 | 772 | 1.01:1 |
| SliderMinimalPerf.default | 1708 | 1686 | 1.01:1 |
| SplitButtonMinimalPerf.default | 4618 | 4582 | 1.01:1 |
| TableManyItemsPerf.default | 1971 | 1946 | 1.01:1 |
| TextMinimalPerf.default | 346 | 343 | 1.01:1 |
| CustomToolbarPrototype.default | 2768 | 2754 | 1.01:1 |
| TooltipMinimalPerf.default | 1074 | 1068 | 1.01:1 |
| VideoMinimalPerf.default | 647 | 639 | 1.01:1 |
| AvatarMinimalPerf.default | 195 | 195 | 1:1 |
| CheckboxMinimalPerf.default | 2804 | 2816 | 1:1 |
| EmbedMinimalPerf.default | 4346 | 4335 | 1:1 |
| MenuMinimalPerf.default | 862 | 858 | 1:1 |
| TreeWith60ListItems.default | 169 | 169 | 1:1 |
| ChatWithPopoverPerf.default | 370 | 375 | 0.99:1 |
| DatepickerMinimalPerf.default | 5959 | 6037 | 0.99:1 |
| ListWith60ListItems.default | 671 | 675 | 0.99:1 |
| PortalMinimalPerf.default | 167 | 168 | 0.99:1 |
| ProviderMinimalPerf.default | 400 | 406 | 0.99:1 |
| ButtonOverridesMissPerf.default | 1512 | 1548 | 0.98:1 |
| CarouselMinimalPerf.default | 466 | 476 | 0.98:1 |
| RosterPerf.default | 1137 | 1163 | 0.98:1 |
| ProviderMergeThemesPerf.default | 1289 | 1316 | 0.98:1 |
| ImageMinimalPerf.default | 368 | 381 | 0.97:1 |
| ToolbarMinimalPerf.default | 940 | 970 | 0.97:1 |
| AnimationMinimalPerf.default | 548 | 569 | 0.96:1 |
| ItemLayoutMinimalPerf.default | 1190 | 1237 | 0.96:1 |
| LoaderMinimalPerf.default | 680 | 707 | 0.96:1 |
| RefMinimalPerf.default | 238 | 249 | 0.96:1 |
| SegmentMinimalPerf.default | 343 | 358 | 0.96:1 |
| ButtonMinimalPerf.default | 165 | 174 | 0.95:1 |
| ChatMinimalPerf.default | 747 | 793 | 0.94:1 |
| ReactionMinimalPerf.default | 357 | 380 | 0.94:1 |
| TreeMinimalPerf.default | 794 | 849 | 0.94:1 |
| AlertMinimalPerf.default | 251 | 269 | 0.93:1 |
| HeaderSlotsPerf.default | 736 | 795 | 0.93:1 |
| LabelMinimalPerf.default | 374 | 405 | 0.92:1 |
| ChatDuplicateMessagesPerf.default | 281 | 314 | 0.89:1 |
This reverts commit c8128d4.
|
|
||
| // when press left click on Dialog content and hold, and mouse up on Dialog overlay, Dialog should keep open | ||
| const isMouseDownInsideContent = React.useRef(false); | ||
| const registerMouseDownOnDialogContent = (e: React.MouseEvent) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be testable in cypress by triggering a mousedown followed by a click somewhere else ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heyy, if I do
cy.trigger('mousedown').
trigger('mousemove', {clientX: 0, clientY: 0}). // move mouse to top left corner of page
trigger('mouseup')
It mimics the behavior of dragging mouse from content to outside of content. But unlike browser, cypress will not trigger an automatic click event after that.
And if I chain it with a .trigger('click'), the test would be testing "clicking outside of dialog closes it". And it lost the purpose of testing the automatic click triggered after dragging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if I chain it with a .trigger('click'), the test would be testing "clicking outside of dialog closes it". And it lost the purpose of testing the automatic click triggered after dragging.
but if you chain it with trigger('click') the dialog should still be open right ? since there is no other way for isMouseDownInsideContenxt to be reset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha I see what you meant. Let me try adding some tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahaa it worked ❤️ on cypress with my change chained 'click' does not close dialog
| cy.clickOn(trigger); | ||
| cy.visible(cancelButton); | ||
|
|
||
| cy.get(cancelButton).trigger('mousedown', { eventConstructor: 'MouseEvent', button: 0 }).trigger('mousemove', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add some comments here wth you are trying to do
… on overlay (microsoft#22849) * check mouse down * e2e fix * chglog * Revert "e2e fix" This reverts commit c8128d4. * e2e * comments on test
… on overlay (microsoft#22849) * check mouse down * e2e fix * chglog * Revert "e2e fix" This reverts commit c8128d4. * e2e * comments on test
Current Behavior
When a Dialog is opened, press click on content and release outside of Dialog will close the Dialog.
New Behavior
Press click on Dialog content and release outside of it will not close the Dialog.
Fixes:
According to click event definition:
press mouse on dialog content and release outside will cause a click event to be fired on dialog overlay.
Events fired during this process: mousedown on content -> mousemove -> mouseup on dialog overlay -> click on dialog overlay.
The fix is to use a ref to register mousedown on content, and on click event handler, check this ref to decide if dialog should be closed.
e2e tests was added