Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const updatedChildren = React.Children.map(children, child => {
if (
(isComponentType(child, 'MenuItem') && !child.props.disabled) ||
isComponentType(child, 'FocusableMenuItem')
) {
return React.cloneElement(child, {
ref: (ref: HTMLElement) => {
refs.push(ref);
if (
open &&
refs.length === 1 &&
hasSetInitialFocus.current === false
) {
refs[0].focus();
setFocused(refs[0]);
hasSetInitialFocus.current = true;
}
},
onFocus: (e: Event) => setFocused(e.target as HTMLElement),
});
const updatedChildren = React.Children.map(children, child => {
if (
(isComponentType(child, 'MenuItem') && !child.props.disabled) ||
isComponentType(child, 'FocusableMenuItem')
) {
return React.cloneElement(child, {
ref: (ref: HTMLElement) => {
refs.push(ref);
if (
open &&
refs.length === 1 &&
hasSetInitialFocus.current === false
) {
refs[0].focus();
setFocused(refs[0]);
hasSetInitialFocus.current = true;
}
},
onFocus: (e: Event) => setFocused(e.target as HTMLElement),
const tabs = React.Children.map(children, (child, index) => {
if (!isComponentType(child, 'Tab')) {
return child;
}
return React.cloneElement(child, {
key: index,
ariaControl: `tab-${index}`,
selected: selected === index,
});
});