Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(event: React.MouseEvent) => {
if (options.disabled) {
event.stopPropagation();
event.preventDefault();
return;
}
const self = event.currentTarget as HTMLElement;
const target = event.target as HTMLElement;
if (isSafariOrFirefoxOnMac && isButton(self) && self.contains(target)) {
event.preventDefault();
const isFocusControl =
isFocusable(target) || target instanceof HTMLLabelElement;
if (!hasFocusWithin(self) || self === target || !isFocusControl) {
self.focus();
}
}
if (htmlOnMouseDown) {
htmlOnMouseDown(event);
}
},
[options.disabled, htmlOnMouseDown]
React.useEffect(() => {
if (!ref.current) {
warning(
true,
"[reakit/Rover]",
"Can't focus rover component because `ref` wasn't passed to component.",
"See https://reakit.io/docs/rover"
);
return;
}
if (options.unstable_moves && focused && !hasFocusWithin(ref.current)) {
ref.current.focus();
}
}, [focused, options.unstable_moves]);