Skip to content

Commit 4e33e1c

Browse files
jas7457chloerice
andauthored
[IndexTable, ProgressBar] - stop console.errors being reported about findDOMNode (#7925)
<!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ### WHY are these changes introduced? While developing in another repo using Polaris, I am getting console.errors about findDOMNode being deprecated. This is because the `CSSTransition` component from `react-transition-group` was not being passed a `nodeRef` properly. This change will properly pass the `nodeRef` and stop the console.errors. <!-- Context about the problem that’s being addressed. --> ### WHAT is this pull request doing? Passes the correct prop so that CSSTransition will work properly and React won't complain. [Without change](https://screenshot.click/15-43-beovu-byqtb.mp4) vs [with change](https://screenshot.click/15-44-344aj-f0r4h.mp4). <!-- Summary of the changes committed. Before / after screenshots are appreciated for UI changes. Make sure to include alt text that describes the screenshot. If you include an animated gif showing your change, wrapping it in a details tag is recommended. Gifs usually autoplay, which can cause accessibility issues for people reviewing your PR: <details> <summary>Summary of your gif(s)</summary> <img src="..." alt="Description of what the gif shows"> </details> --> <!-- ℹ️ Delete the following for small / trivial changes --> ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) <!-- Give as much information as needed to experiment with the component in the playground. --> ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - not sure how? the doc just links to cross-browser testing, is this necessary? - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - N/A - [ ] Updated the component's `README.md` with documentation changes - N/A - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide - N/A Co-authored-by: Chloe Rice <chloerice@users.noreply.github.com>
1 parent 81fd3fd commit 4e33e1c

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

.changeset/mean-bananas-drum.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Updated `IndexTable` and `ProgressBar` to no longer log errors about deprecated `React.findDOMNode`

polaris-react/src/components/IndexTable/IndexTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function IndexTableBase({
148148
const scrollableContainerElement = useRef<HTMLDivElement>(null);
149149
const tableElement = useRef<HTMLTableElement>(null);
150150
const condensedListElement = useRef<HTMLUListElement>(null);
151+
const loadingElement = useRef<HTMLDivElement>(null);
151152

152153
const [tableInitialized, setTableInitialized] = useState(false);
153154
const [stickyWrapper, setStickyWrapper] = useState<HTMLElement | null>(null);
@@ -512,10 +513,11 @@ function IndexTableBase({
512513
in={loading}
513514
classNames={loadingTransitionClassNames}
514515
timeout={parseInt(motion['duration-100'], 10)}
516+
nodeRef={loadingElement}
515517
appear
516518
unmountOnExit
517519
>
518-
<div className={styles.LoadingPanel}>
520+
<div className={styles.LoadingPanel} ref={loadingElement}>
519521
<div className={styles.LoadingPanelRow}>
520522
<Spinner size="small" />
521523
<span className={styles.LoadingPanelText}>

polaris-react/src/components/Modal/components/Dialog/Dialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {TrapFocus} from '../../../TrapFocus';
1010

1111
import styles from './Dialog.scss';
1212

13+
type CSSTransitionProps = React.ComponentProps<typeof CSSTransition>;
14+
1315
export interface DialogProps {
1416
labelledBy?: string;
1517
instant?: boolean;
@@ -117,7 +119,7 @@ const fadeUpClasses = {
117119
exitActive: classNames(styles.animateFadeUp, styles.exited),
118120
};
119121

120-
function FadeUp({children, ...props}: any) {
122+
function FadeUp({children, ...props}: CSSTransitionProps) {
121123
return (
122124
<CSSTransition {...props} classNames={fadeUpClasses}>
123125
{children}

polaris-react/src/components/ProgressBar/ProgressBar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, {useRef} from 'react';
22
import {CSSTransition} from 'react-transition-group';
33
import {motion} from '@shopify/polaris-tokens';
44

@@ -45,6 +45,7 @@ export function ProgressBar({
4545
ariaLabelledBy,
4646
}: ProgressBarProps) {
4747
const i18n = useI18n();
48+
const indicatorRef = useRef<HTMLDivElement>(null);
4849

4950
const className = classNames(
5051
styles.ProgressBar,
@@ -78,12 +79,14 @@ export function ProgressBar({
7879
in
7980
appear
8081
timeout={parseInt(progressBarDuration, 10)}
82+
nodeRef={indicatorRef}
8183
classNames={{
8284
appearActive: styles.IndicatorAppearActive,
8385
appearDone: styles.IndicatorAppearDone,
8486
}}
8587
>
8688
<div
89+
ref={indicatorRef}
8790
className={styles.Indicator}
8891
style={
8992
{

0 commit comments

Comments
 (0)