mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-29 06:58:30 +01:00
Merge pull request #16354 from Kashargul/buttonfocus
buttons no longer steal focus
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user