Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unbroken_exclusions
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ URL not found https://docs.github.com/get-started/quickstart while parsing CONTR
!packages/@rnw-scripts/format-files/node_modules
!packages/@rnw-scripts/promote-release/node_modules
!.github/ISSUE_TEMPLATE
!.github/security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "[Win32] view.focus sometimes skips setting focus",
"packageName": "@office-iss/react-native-win32",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import type {

import {Commands as AndroidTextInputCommands} from '../../Components/TextInput/AndroidTextInputNativeComponent';
import {Commands as iOSTextInputCommands} from '../../Components/TextInput/RCTSingelineTextInputNativeComponent';

import {UIManager} from 'react-native';
import {Commands as Win32TextInputCommands} from '../../Components/TextInput/Win32TextInputNativeComponent';

const {findNodeHandle} = require('../../ReactNative/RendererProxy');
const Platform = require('../../Utilities/Platform');
Expand Down Expand Up @@ -106,7 +105,16 @@ function focusTextInput(textField: ?ComponentRef) {
return;
}

if (textField != null) {
// [Win32
if (Platform.OS === 'win32' && textField != null) {
// On Windows, we cannot test if the currentlyFocusedInputRef equals the
// target ref because the call to focus on the target ref may occur before
// an onBlur event for the target ref has been dispatched to JS but after
// the target ref has lost native focus.
focusInput(textField);
Win32TextInputCommands.focus(textField);
// Win32]
} else if (textField != null) {
const fieldCanBeFocused =
currentlyFocusedInputRef !== textField &&
// $FlowFixMe - `currentProps` is missing in `NativeMethods`
Expand All @@ -126,11 +134,6 @@ function focusTextInput(textField: ?ComponentRef) {
} else if (Platform.OS === 'android') {
AndroidTextInputCommands.focus(textField);
}
// [Win32
else if (Platform.OS === 'win32') {
UIManager.focus(findNodeHandle(textField));
}
// Win32]
}
}

Expand Down Expand Up @@ -164,7 +167,7 @@ function blurTextInput(textField: ?ComponentRef) {
}
// [Win32
else if (Platform.OS === 'win32') {
UIManager.blur(findNodeHandle(textField));
Win32TextInputCommands.blur(textField);
}
// Win32]
}
Expand Down