mirror of
https://github.com/excalidraw/excalidraw.git
synced 2024-11-10 11:35:52 +01:00
fix: don't allow blank space in collab name (#6211)
* don't allow blank space in collab name * add spec * prevent blank
This commit is contained in:
parent
8c1168ef33
commit
c9d18ecab6
@ -21,7 +21,7 @@ export const getClientColors = (clientId: string, appState: AppState) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getClientInitials = (userName?: string | null) => {
|
export const getClientInitials = (userName?: string | null) => {
|
||||||
if (!userName) {
|
if (!userName?.trim()) {
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
return userName.trim()[0].toUpperCase();
|
return userName.trim()[0].toUpperCase();
|
||||||
|
@ -144,7 +144,7 @@ const RoomDialog = ({
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="username"
|
id="username"
|
||||||
value={username || ""}
|
value={username.trim() || ""}
|
||||||
className="RoomDialog-username TextInput"
|
className="RoomDialog-username TextInput"
|
||||||
onChange={(event) => onUsernameChange(event.target.value)}
|
onChange={(event) => onUsernameChange(event.target.value)}
|
||||||
onKeyPress={(event) => event.key === "Enter" && handleClose()}
|
onKeyPress={(event) => event.key === "Enter" && handleClose()}
|
||||||
|
@ -36,4 +36,9 @@ describe("getClientInitials", () => {
|
|||||||
result = getClientInitials(null);
|
result = getClientInitials(null);
|
||||||
expect(result).toBe("?");
|
expect(result).toBe("?");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns "?" when value is blank', () => {
|
||||||
|
const result = getClientInitials(" ");
|
||||||
|
expect(result).toBe("?");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user