fix(react-dialog): set transition status to undefined for test environment#29755
Merged
Conversation
YuanboXue-Amber
marked this pull request as draft
November 6, 2023 10:53
Collaborator
Perf Analysis (
|
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| FluentProviderWithTheme | mount | 83 | 81 | 10 | Possible regression |
All results
| Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
|---|---|---|---|---|---|
| Avatar | mount | 628 | 641 | 5000 | |
| Button | mount | 316 | 315 | 5000 | |
| Field | mount | 1134 | 1156 | 5000 | |
| FluentProvider | mount | 702 | 718 | 5000 | |
| FluentProviderWithTheme | mount | 83 | 81 | 10 | Possible regression |
| FluentProviderWithTheme | virtual-rerender | 70 | 70 | 10 | |
| FluentProviderWithTheme | virtual-rerender-with-unmount | 86 | 81 | 10 | |
| MakeStyles | mount | 901 | 881 | 50000 | |
| Persona | mount | 1760 | 1744 | 5000 | |
| SpinButton | mount | 1387 | 1405 | 5000 |
|
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 93d56c7:
|
Collaborator
📊 Bundle size reportUnchanged fixtures
|
YuanboXue-Amber
marked this pull request as ready for review
November 6, 2023 11:02
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: aa664abe172b5ceedb63bafdc690ac2e82ab48db (build) |
Collaborator
🕵 fluentuiv9 No visual regressions between this PR and main |
layershifter
approved these changes
Nov 6, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previous Behavior
DialogTransitionContextis always defined and has valueenteredfor test environment (#29692). However,DialogSurfacehas base styleopacity: 0, and when transition status isentered, it merges styleopacity: 1. To apply stylesDialogSurfaceusesmakeResetStyles()&makeStyles(), so will get following:In this case, tests for
DialogSurfaceusingjest-dom&.toBeVisible()can fail. This is ajsdombug - it cannot detect style override with 'opacity' nor 'visibility' (check Stackblitz). This happens becauseDialogSurfacehas as base styleopacity:0:getComputedStyles(DialogSurfaceElement).opacityinjsdomreturns0and ignores theopacity:1style override 💥Odd thing is, fix #29692 is good enough for a simple test that asserts something within
DialogSurfacevia '.toBeVisible()'. But when a random style override is added toDialogSurface, the test can fail with the same reason. This PR added a unit test case for this.New Behavior
DialogTransitionContextisundefinedfor test environment.DialogSurfaceadds styleopacity:0only when DialogTransitionContext is defined.Test is green and animation works as is.
Discarded solution
I also considered simply moving
opacity:0from baseStyle to 'unmounted' state's style, but it breaks animation:Screen.Recording.2023-11-06.at.11.57.34.mov
note that DialogSurface shows up immediately after open. This is because transition state is
exitedenteringand thenenteredwhen Dialog is opened. Addingopacity:0based on state is not as safe option compare to not adding it at all for test environment.