Skip to content

Commit

Permalink
UserStatusScreen: Trim entered text status before interpreting it
Browse files Browse the repository at this point in the history
This seems helpful. It's easy to end up with leading or trailing
spaces in a text input, and want them to be treated as though they
weren't there. The server may even trim the text status too, I'm not
sure.

Note that we don't do this by fussing with the actual value of the
text input. That'd be easy to do, since we're using Input as a
controlled input -- but it would be a misuse of that control. In
particular, we'd introduce a bug like the following, on a topic
input, fixed in zulip#5098:

> Some bug prevented adding a space at the end of what I was typing
> specifically on the topic and maybe stream input (the space would
> appear and then immediately disappear, I think) ... so I was only
> able to create the topic "bog plants" by typing "bogplants" and
> then moving my cursor.
  • Loading branch information
chrisbobbe committed Mar 8, 2022
1 parent 70a4c12 commit 80d7bc1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/user-statuses/UserStatusScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type Props = $ReadOnly<{|
route: RouteProp<'user-status', void>,
|}>;

const statusTextFromInputValue = (v: string): $PropertyType<UserStatus, 'status_text'> => v || null;
const statusTextFromInputValue = (v: string): $PropertyType<UserStatus, 'status_text'> =>
v.trim() || null;

const inputValueFromStatusText = (t: $PropertyType<UserStatus, 'status_text'>): string => t ?? '';

Expand Down

0 comments on commit 80d7bc1

Please sign in to comment.