UNPKG

@wordpress/block-editor

Version:
39 lines (37 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = AriaReferencedText; var _element = require("@wordpress/element"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * A component specifically designed to be used as an element referenced * by ARIA attributes such as `aria-labelledby` or `aria-describedby`. * * @param {Object} props Props. * @param {import('react').ReactNode} props.children */function AriaReferencedText({ children, ...props }) { const ref = (0, _element.useRef)(); (0, _element.useEffect)(() => { if (ref.current) { // This seems like a no-op, but it fixes a bug in Firefox where // it fails to recompute the text when only the text node changes. // @see https://github.com/WordPress/gutenberg/pull/51035 ref.current.textContent = ref.current.textContent; } }, [children]); return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { hidden: true, ...props, ref: ref, children: children }); } //# sourceMappingURL=aria-referenced-text.js.map