lobe-chat icon indicating copy to clipboard operation
lobe-chat copied to clipboard

🐛 fix: user feedback for empty/long group names in create/edit group modals

Open ramu-narasinga opened this issue 2 months ago • 5 comments

💻 变更类型 | Change Type

  • [ ] ✨ feat
  • [x] 🐛 fix
  • [ ] ♻️ refactor
  • [ ] 💄 style
  • [ ] 👷 build
  • [ ] ⚡️ perf
  • [ ] 📝 docs
  • [ ] 🔨 chore

🔀 变更说明 | Description of Change

To show an alert when the user submits an empty or long group name in Create Group and Rename Group Modals.

📝 补充信息 | Additional Information

  1. Removed the below if block in CreateModal
 onOk={async (e: MouseEvent<HTMLButtonElement>) => {
            if (!input) return;

To allow the input length check that shows an alert if the title does not meet the criteria.

  1. Removed the below if block in RenameGroupModal
 onOk={async (e: MouseEvent<HTMLButtonElement>) => {
            if (!input) return;

To allow the input length check that shows an alert if the title does not meet the criteria.

2.1 And this forced to ensure types are valid for input state variable, as a result input state is initialized to '' (empty string - following the same convention in CreateGroupModal)

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

2.2 Added fallback to empty string in the onCancel, in case the group.name is empty.

onCancel={(e) => {
        setInput(group?.name ?? '');
        onCancel?.(e);
      }}

ramu-narasinga avatar Dec 18 '24 20:12 ramu-narasinga