@mui/material
Version:
Material UI is an open-source React component library that implements Google's Material Design. It's comprehensive and can be used in production out of the box.
24 lines (23 loc) • 546 B
JavaScript
;
'use client';
/**
* If `focusSource` is present, attempt to pass `focusVisible` through `focus()` options.
* Fall back to a plain focus call when the browser does not support it.
*/
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = focusWithVisible;
function focusWithVisible(element, focusSource) {
if (focusSource == null) {
element.focus();
return;
}
try {
element.focus({
focusVisible: focusSource === 'keyboard'
});
} catch (error) {
element.focus();
}
}