Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
React.useEffect(() => {
const self = ref.current;
if (!self) return;
if (!isButton(self)) {
if (self.tagName !== "A") {
setRole("button");
}
setType(undefined);
}
}, []);
(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]