Skip to content

Commit 4304dea

Browse files
committed
UserStatusScreen: Trim entered text status before interpreting it
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 #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.
1 parent 32a127d commit 4304dea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/user-statuses/UserStatusScreen.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ type Props = $ReadOnly<{|
3737
route: RouteProp<'user-status', void>,
3838
|}>;
3939

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

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

0 commit comments

Comments
 (0)