-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Provide nodeRef to Transition to fix StrictMode warning #3865
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8746af2
Update react-transition-group
mischnic 5388c6e
Pass nodeRef into Transition
mischnic e0419ca
WIP
mischnic e0f3e31
fix docs build
snowystinger 07d7920
Remove a few ignores and explain the last remaining one
snowystinger 3d788c5
fixing some overlay refs passed to Transition
LFDanLu 976d234
fixing transition for Modal and Tray
LFDanLu 7285ef9
actually use wrapper refs
LFDanLu c13b2a7
fixing actionbar ref to Transition
LFDanLu f2c9057
adding wrapper to attach transition nodeRef
LFDanLu ba046e2
fixing rebase
LFDanLu 4104d44
fix lint
LFDanLu 9bfbda6
fix yarn.lock
LFDanLu fcc15e5
fix Tray and Modal types
LFDanLu b04f490
fix TS strict
LFDanLu c4feb52
Merge branch 'main' into strict-mode-fixes
LFDanLu 9559afb
adding comments
LFDanLu 153042e
Merge branch 'main' into strict-mode-fixes
LFDanLu d8cd27e
remove ref from Underlay
LFDanLu ee03365
Merge branch 'main' into strict-mode-fixes
LFDanLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ import {DOMRef, StyleProps} from '@react-types/shared'; | |
| import {Overlay} from './Overlay'; | ||
| import {OverlayTriggerState} from '@react-stately/overlays'; | ||
| import overrideStyles from './overlays.css'; | ||
| import React, {forwardRef, ReactNode, RefObject, useRef, useState} from 'react'; | ||
| import React, {forwardRef, MutableRefObject, ReactNode, RefObject, useRef, useState} from 'react'; | ||
| import styles from '@adobe/spectrum-css-temp/components/popover/vars.css'; | ||
| import {Underlay} from './Underlay'; | ||
| import {useLayoutEffect} from '@react-aria/utils'; | ||
|
|
@@ -28,7 +28,8 @@ interface PopoverProps extends Omit<AriaPopoverProps, 'popoverRef' | 'maxHeight' | |
| } | ||
|
|
||
| interface PopoverWrapperProps extends PopoverProps { | ||
| isOpen?: boolean | ||
| isOpen?: boolean, | ||
| wrapperRef: MutableRefObject<HTMLDivElement> | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -52,10 +53,11 @@ function Popover(props: PopoverProps, ref: DOMRef<HTMLDivElement>) { | |
| ...otherProps | ||
| } = props; | ||
| let domRef = useDOMRef(ref); | ||
| let wrapperRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| return ( | ||
| <Overlay {...otherProps} isOpen={state.isOpen}> | ||
| <PopoverWrapper ref={domRef} {...props}> | ||
| <Overlay {...otherProps} isOpen={state.isOpen} nodeRef={wrapperRef}> | ||
| <PopoverWrapper ref={domRef} {...props} wrapperRef={wrapperRef}> | ||
| {children} | ||
| </PopoverWrapper> | ||
| </Overlay> | ||
|
|
@@ -68,7 +70,8 @@ const PopoverWrapper = forwardRef((props: PopoverWrapperProps, ref: RefObject<HT | |
| isOpen, | ||
| hideArrow, | ||
| isNonModal, | ||
| state | ||
| state, | ||
| wrapperRef | ||
| } = props; | ||
| let {styleProps} = useStyleProps(props); | ||
|
|
||
|
|
@@ -78,8 +81,9 @@ const PopoverWrapper = forwardRef((props: PopoverWrapperProps, ref: RefObject<HT | |
| maxHeight: null | ||
| }, state); | ||
|
|
||
| // Attach Transition's nodeRef to outer most wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231 | ||
| return ( | ||
| <> | ||
| <div ref={wrapperRef}> | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could instead attach the nodeRef to the Underlay, however it doesn't exist in the |
||
| {!isNonModal && <Underlay isTransparent {...underlayProps} isOpen={isOpen} /> } | ||
| <div | ||
| {...styleProps} | ||
|
|
@@ -115,7 +119,7 @@ const PopoverWrapper = forwardRef((props: PopoverWrapperProps, ref: RefObject<HT | |
| )} | ||
| <DismissButton onDismiss={state.close} /> | ||
| </div> | ||
| </> | ||
| </div> | ||
| ); | ||
| }); | ||
|
|
||
|
|
||
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
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
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
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.
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.
Why did you add the comment here and not to Modal.tsx or Tray.txs?
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.
No particular reason, I can definitely add that to those components as well