Skip to content

Commit

Permalink
🐛 fix: user feedback for empty/long group names in create/edit group …
Browse files Browse the repository at this point in the history
…modals (lobehub#6247)
  • Loading branch information
ramu-narasinga authored Feb 17, 2025
1 parent 32f442d commit 25c80d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ const CreateGroupModal = memo<CreateGroupModalProps>(
onCancel?.(e);
}}
onOk={async (e: MouseEvent<HTMLButtonElement>) => {
if (!input) return;

if (input.length === 0 || input.length > 20)
return message.warning(t('sessionGroup.tooLong'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const RenameGroupModal = memo<RenameGroupModalProps>(({ id, open, onCancel }) =>
const updateSessionGroupName = useSessionStore((s) => s.updateSessionGroupName);
const group = useSessionStore((s) => sessionGroupSelectors.getGroupById(id)(s), isEqual);

const [input, setInput] = useState<string>();
const [input, setInput] = useState<string>('');
const [loading, setLoading] = useState(false);

const { message } = App.useApp();

useEffect(() => {
setInput(group?.name);
setInput(group?.name ?? '');
}, [group]);

return (
Expand All @@ -32,11 +32,10 @@ const RenameGroupModal = memo<RenameGroupModalProps>(({ id, open, onCancel }) =>
destroyOnClose
okButtonProps={{ loading }}
onCancel={(e) => {
setInput(group?.name);
setInput(group?.name ?? '');
onCancel?.(e);
}}
onOk={async (e) => {
if (!input) return;
if (input.length === 0 || input.length > 20)
return message.warning(t('sessionGroup.tooLong'));
setLoading(true);
Expand Down

0 comments on commit 25c80d1

Please sign in to comment.