Files
formipay/node_modules/@wordpress/components/build-module/tree-grid/roving-tab-index-item.js
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

48 lines
1.4 KiB
JavaScript

import { createElement } from "react";
/**
* WordPress dependencies
*/
import { useRef, forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useRovingTabIndexContext } from './roving-tab-index-context';
export const RovingTabIndexItem = forwardRef(function UnforwardedRovingTabIndexItem({
children,
as: Component,
...props
}, forwardedRef) {
const localRef = useRef();
const ref = forwardedRef || localRef;
// @ts-expect-error - We actually want to throw an error if this is undefined.
const {
lastFocusedElement,
setLastFocusedElement
} = useRovingTabIndexContext();
let tabIndex;
if (lastFocusedElement) {
tabIndex = lastFocusedElement === (
// TODO: The original implementation simply used `ref.current` here, assuming
// that a forwarded ref would always be an object, which is not necessarily true.
// This workaround maintains the original runtime behavior in a type-safe way,
// but should be revisited.
'current' in ref ? ref.current : undefined) ? 0 : -1;
}
const onFocus = event => setLastFocusedElement?.(event.target);
const allProps = {
ref,
tabIndex,
onFocus,
...props
};
if (typeof children === 'function') {
return children(allProps);
}
if (!Component) return null;
return createElement(Component, {
...allProps
}, children);
});
export default RovingTabIndexItem;
//# sourceMappingURL=roving-tab-index-item.js.map