Skip to content
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

Components: refactor Tooltip to ignore exhaustive-deps #45043

Merged
merged 3 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- `Sandbox`: updated to satisfy `react/exhaustive-deps` eslint rule ([#44378](https://github.com/WordPress/gutenberg/pull/44378))
- `FontSizePicker`: Convert to TypeScript ([#44449](https://github.com/WordPress/gutenberg/pull/44449)).
- `FontSizePicker`: Replace SCSS with Emotion + components ([#44483](https://github.com/WordPress/gutenberg/pull/44483)).
- `Tooltip`: updated to ignore `react/exhaustive-deps` eslint rule ([#45043](https://github.com/WordPress/gutenberg/pull/45043))

### Experimental

Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ function Tooltip( props ) {
document.removeEventListener( 'mouseup', cancelIsMouseDown );
};

// Ignore reason: updating the deps array here could cause unexpected changes in behavior.
// Deferring until a more detailed investigation/refactor can be performed.
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect( () => clearOnUnmount, [] );

if ( Children.count( children ) !== 1 ) {
Expand Down
15 changes: 15 additions & 0 deletions packages/components/src/tooltip/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const useKeyboardVisibility = () => {
showListener.remove();
hideListener.remove();
};
// Disable reason: deferring this refactor to the native team.
// see https://github.com/WordPress/gutenberg/pull/41166
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [] );

return keyboardVisible;
Expand Down Expand Up @@ -102,6 +105,9 @@ const Tooltip = ( {
} );
}
return () => onHandleScreenTouch( null );
// Disable reason: deferring this refactor to the native team.
// see https://github.com/WordPress/gutenberg/pull/41166
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ visible ] );

// Manage visibility animation.
Expand All @@ -115,6 +121,9 @@ const Tooltip = ( {
setAnimating( true );
startAnimation();
}
// Disable reason: deferring this refactor to the native team.
// see https://github.com/WordPress/gutenberg/pull/41166
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ visible ] );

// Manage tooltip visibility and position in relation to keyboard.
Expand All @@ -133,6 +142,9 @@ const Tooltip = ( {
setAnimating( true );
setVisible( false );
}
// Disable reason: deferring this refactor to the native team.
// see https://github.com/WordPress/gutenberg/pull/41166
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ visible, keyboardVisible ] );

// Manage tooltip position during keyboard frame changes.
Expand Down Expand Up @@ -261,6 +273,9 @@ const TooltipSlot = ( { children, ...rest } ) => {
setHandleScreenTouch( null );
};
// Memoize context value to avoid unnecessary rerenders of the Provider's children
// Disable reason: deferring this refactor to the native team.
// see https://github.com/WordPress/gutenberg/pull/41166
// eslint-disable-next-line react-hooks/exhaustive-deps
const value = useMemo( () => ( { onHandleScreenTouch } ) );

return (
Expand Down