From 95551d91cf07871842b98d6270391ebe9608e589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Mon, 8 Feb 2021 16:08:34 +0200 Subject: [PATCH] Try: useMergeRefs (#27768) * Try: useMergeRefs * update lock file * Rebase fixes * Add docs * Clearer documentation * wip * wip * Add docs for unit tests * Convert new additions --- package-lock.json | 13 +- packages/block-editor/package.json | 1 - .../src/components/iframe/index.js | 4 +- packages/components/package.json | 1 - packages/components/src/modal/frame.js | 4 +- packages/components/src/panel/body.js | 5 +- packages/components/src/popover/index.js | 14 +- packages/compose/README.md | 18 ++ packages/compose/package.json | 1 - .../src/hooks/use-callback-ref/index.js | 20 -- .../hooks/use-constrained-tabbing/index.js | 8 +- .../compose/src/hooks/use-dialog/index.js | 13 +- .../src/hooks/use-focus-on-mount/index.js | 9 +- .../src/hooks/use-focus-return/index.js | 9 +- .../compose/src/hooks/use-merge-refs/index.js | 74 ++++++ .../src/hooks/use-merge-refs/test/index.js | 221 ++++++++++++++++++ packages/compose/src/index.js | 1 + packages/edit-post/package.json | 1 - .../src/components/visual-editor/index.js | 14 +- packages/interface/package.json | 4 +- .../components/interface-skeleton/index.js | 9 +- 21 files changed, 344 insertions(+), 100 deletions(-) delete mode 100644 packages/compose/src/hooks/use-callback-ref/index.js create mode 100644 packages/compose/src/hooks/use-merge-refs/index.js create mode 100644 packages/compose/src/hooks/use-merge-refs/test/index.js diff --git a/package-lock.json b/package-lock.json index 2ac5ed04fb7fc9..22c96db849cbb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11827,7 +11827,6 @@ "lodash": "^4.17.19", "memize": "^1.1.0", "react-autosize-textarea": "^7.1.0", - "react-merge-refs": "^1.0.0", "react-spring": "^8.0.19", "redux-multi": "^0.1.12", "rememo": "^3.0.0", @@ -11956,7 +11955,6 @@ "moment": "^2.22.1", "re-resizable": "^6.4.0", "react-dates": "^17.1.1", - "react-merge-refs": "^1.0.0", "react-resize-aware": "^3.1.0", "react-spring": "^8.0.20", "react-use-gesture": "^9.0.0", @@ -11980,7 +11978,6 @@ "lodash": "^4.17.19", "memize": "^1.1.0", "mousetrap": "^1.6.5", - "react-merge-refs": "^1.0.0", "react-resize-aware": "^3.1.0", "use-memo-one": "^1.1.1" } @@ -12199,7 +12196,6 @@ "classnames": "^2.2.5", "lodash": "^4.17.19", "memize": "^1.1.0", - "react-merge-refs": "^1.0.0", "rememo": "^3.0.0" } }, @@ -12421,6 +12417,7 @@ "requires": { "@babel/runtime": "^7.12.5", "@wordpress/components": "file:packages/components", + "@wordpress/compose": "file:packages/compose", "@wordpress/data": "file:packages/data", "@wordpress/deprecated": "file:packages/deprecated", "@wordpress/element": "file:packages/element", @@ -12429,8 +12426,7 @@ "@wordpress/plugins": "file:packages/plugins", "@wordpress/viewport": "file:packages/viewport", "classnames": "^2.2.5", - "lodash": "^4.17.19", - "react-merge-refs": "^1.0.0" + "lodash": "^4.17.19" } }, "@wordpress/is-shallow-equal": { @@ -47167,11 +47163,6 @@ "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==", "dev": true }, - "react-merge-refs": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/react-merge-refs/-/react-merge-refs-1.0.0.tgz", - "integrity": "sha512-VkvWuCR5VoTjb+VYUcOjkFo66HDv1Hw8VjKcwQtWr2lJnT8g7epRRyfz8+Zkl2WhwqNeqR0gIe0XYrBa9ePeXg==" - }, "react-moment-proptypes": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/react-moment-proptypes/-/react-moment-proptypes-1.7.0.tgz", diff --git a/packages/block-editor/package.json b/packages/block-editor/package.json index 0e755c2b46b4a8..d8c47dcf9426b1 100644 --- a/packages/block-editor/package.json +++ b/packages/block-editor/package.json @@ -60,7 +60,6 @@ "lodash": "^4.17.19", "memize": "^1.1.0", "react-autosize-textarea": "^7.1.0", - "react-merge-refs": "^1.0.0", "react-spring": "^8.0.19", "redux-multi": "^0.1.12", "rememo": "^3.0.0", diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index 32366d1e3863ec..cc0b350cc0f7bc 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -1,7 +1,6 @@ /** * External dependencies */ -import mergeRefs from 'react-merge-refs'; import { compact, map } from 'lodash'; import tinycolor from 'tinycolor2'; @@ -16,6 +15,7 @@ import { forwardRef, } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +import { useMergeRefs } from '@wordpress/compose'; /** * Internal dependencies @@ -211,7 +211,7 @@ function Iframe( { contentRef, editorStyles, children, head, ...props }, ref ) { return (