Merge pull request #16354 from Kashargul/buttonfocus

buttons no longer steal focus
This commit is contained in:
Heroman3003
2024-09-27 21:04:09 +10:00
committed by GitHub
+13 -3
View File
@@ -91,8 +91,20 @@ export const Button = (props: Props) => {
const toDisplay: ReactNode = content || children;
const ref = useRef(null);
function handleButtonClick(event) {
if (!disabled && onClick) {
onClick(event);
if (ref?.current) {
(ref.current as HTMLElement).blur();
}
}
}
let buttonContent = (
<div
ref={ref}
className={classes([
'Button',
fluid && 'Button--fluid',
@@ -114,9 +126,7 @@ export const Button = (props: Props) => {
])}
tabIndex={!disabled ? 0 : undefined}
onClick={(event) => {
if (!disabled && onClick) {
onClick(event);
}
handleButtonClick(event);
}}
onKeyDown={(event) => {
if (!captureKeys) {