Skip to content

Commit 2b6dc06

Browse files
chrisbobbegnprice
authored andcommitted
compose: Decrease jank on message-input focus
By doing the setFocusState call unconditionally. This piece of React state is meant to track when the topic input is focused, when the message input is focused, and (with the true-to-false transition debounced) when either is focused. So if the message input is focused and we don't set that state (as has sometimes been the case until now), it's not working as intended. Fix that by making this setFocusState call unconditional, like it is in handleTopicFocus. This makes a visible improvement in the situation described by this comment: // We weren't showing the topic input when the user tapped on the input // to focus it, but we're about to show it. Focus that, if the user // hasn't already selected a topic. Before, focusState.either was being set later than it should be; it would only happen following that automatic topic focus, when handleTopicFocus was called. Since focusState.either controls whether the topic input is visible, the topic input was appearing a frame or two later than it should -- sometimes even after the topic autocomplete appeared. Eliminating that delay gives a less janky feel.
1 parent f5b7611 commit 2b6dc06

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/compose/ComposeBox.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,8 @@ const ComposeBox: React$AbstractComponent<Props, ImperativeHandle> = forwardRef(
496496
// to focus it, but we're about to show it. Focus that, if the user
497497
// hasn't already selected a topic.
498498
topicInputRef.current?.focus();
499-
} else {
500-
setFocusState(state => ({ ...state, message: true, either: true }));
501499
}
500+
setFocusState(state => ({ ...state, message: true, either: true }));
502501
}, [isEditing, narrow, focusState.either, topicInputState.value, topicInputRef]);
503502

504503
const handleMessageBlur = useCallback(() => {

0 commit comments

Comments
 (0)