@wordpress/block-editor
Version:
44 lines (38 loc) • 1.26 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AriaReferencedText;
var _element = require("@wordpress/element");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
/**
* 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 (0, _element.createElement)("div", (0, _extends2.default)({
hidden: true
}, props, {
ref: ref
}), children);
}
//# sourceMappingURL=aria-referenced-text.js.map