Skip to content

Commit afdbf84

Browse files
authored
FIx double onClick when invoking buttons via keyboard in Windows (#3970)
* Update shouldOnlyFireIfPressed for Windows platforms Currently in Windows platform I'm seeing a bug where invoking a Button via keyboard results in `onClick` being triggered twice, once from `onKeyUp` and once from `onKeyPressed`. This seemed like the appropriate place to make a fix, but let me know if there's a better place. * Change files
1 parent ec8a8fc commit afdbf84

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Update shouldOnlyFireIfPressed for Windows platforms",
4+
"packageName": "@fluentui-react-native/button",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/components/Button/src/useButton.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { ButtonProps, ButtonInfo } from './Button.types';
1313
// like the button firing after you tab to it white Enter is pressed
1414
// and then releasing Enter, or the Menu reopening since it closes
1515
// onKeyDown while the Button operates onKeyUp.
16-
const shouldOnlyFireIfPressed = Platform.OS === ('win32' as any);
16+
const shouldOnlyFireIfPressed = Platform.OS === ('win32' as any) || Platform.OS === ('windows' as any);
1717
let isProcessingKeyboardInvocation = false;
1818

1919
export const useButton = (props: ButtonProps): ButtonInfo => {

0 commit comments

Comments
 (0)