Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quote-and-reply: Set topic input when appropriate; focus message input #5723

Merged
merged 6 commits into from
Sep 13, 2023

Conversation

chrisbobbe
Copy link
Contributor

Fixes: #5718

@chrisbobbe chrisbobbe added a-compose/send Compose box, autocomplete, camera/upload, outbox, sending P1 high-priority labels Apr 25, 2023
@chrisbobbe chrisbobbe requested a review from gnprice April 25, 2023 21:34
@chrisbobbe chrisbobbe marked this pull request as draft April 27, 2023 19:20
@chrisbobbe chrisbobbe marked this pull request as ready for review April 27, 2023 19:57
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plan sounds good. One comment below.

Comment on lines 449 to 452
} finally {
setActiveQuoteAndRepliesCount(v => v - 1);
activeInvocations.current = activeInvocations.current.filter(x => x !== serialNumber);
messageInputRef.current?.focus();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning for putting this step in the finally block?

I think it should instead go at the end of the try block. The existing job of this finally block is purely about making sure that the setActiveQuoteAndRepliesCount(v => v + 1) and activeInvocations.current.push at the top of the function always get closed eventually, regardless of whether the invocation succeeds or fails. If it does fail, I think it's probably not helpful to go and focus the input — we haven't successfully set up something for the user to type their reply after.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting, yeah, I agree it seems better to put it at the end of the try. Will test to make sure that doesn't break anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that seems to work fine. Thanks for the catch!

Note that we have logic in `handleMessageFocus` to respond to focus
on the message input by auto-focusing the *topic* input in some
cases. That would be annoying if it happened here: you do a
quote-and-reply, and suddenly the topic input is focused?(!)

But that topic auto-focusing should be defeated in all cases where
it was active. In particular, since the previous commit, the topic
input won't be empty; the logic in `handleMessageFocus` will see
that and skip the auto-focus.

Fixes: zulip#5718
@chrisbobbe
Copy link
Contributor Author

Thanks for the review! Revision pushed.

@gnprice gnprice merged commit e7d3d81 into zulip:main Sep 13, 2023
1 check passed
@gnprice
Copy link
Member

gnprice commented Sep 13, 2023

Thanks! Looks good; merging.

@chrisbobbe chrisbobbe deleted the pr-quote-and-reply-topic branch September 13, 2023 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-compose/send Compose box, autocomplete, camera/upload, outbox, sending P1 high-priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quote and reply deletes topic and moves cursor to topic
2 participants