Skip to content

Commit 1f5d6db

Browse files
chrisbobbegnprice
authored andcommitted
ComposeBox [nfc]: Move setFocusState call to top of function
Following the pattern of handleMessageBlur, handleTopicFocus, and handleTopicBlur.
1 parent 2b6dc06 commit 1f5d6db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compose/ComposeBox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,18 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
486486
);
487487

488488
const handleMessageFocus = useCallback(() => {
489+
setFocusState(state => ({ ...state, message: true, either: true }));
489490
if (
490491
!isEditing
491492
&& isStreamNarrow(narrow)
492-
&& !focusState.either
493+
&& !focusState.either // not affected by setFocusState above; React state is set asynchronously
493494
&& topicInputState.value === ''
494495
) {
495496
// We weren't showing the topic input when the user tapped on the input
496497
// to focus it, but we're about to show it. Focus that, if the user
497498
// hasn't already selected a topic.
498499
topicInputRef.current?.focus();
499500
}
500-
setFocusState(state => ({ ...state, message: true, either: true }));
501501
}, [isEditing, narrow, focusState.either, topicInputState.value, topicInputRef]);
502502

503503
const handleMessageBlur = useCallback(() => {

0 commit comments

Comments
 (0)