Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(InviteToAnswer): Optimising the control logic of the `edit` button

haitaoo6eed25f48cd4
diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx
index 88d12b40..4632ccbc 100644
--- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx
+++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx
@@ -74,17 +74,19 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {
const showAddButton = editing && (!users || users.length < MAX_ASK_NUMBER);
const showInviteDesc = !editing && users?.length === 0;
+ const showEditButton = !readOnly && !editing && users?.length;
+ const showSaveButton = !readOnly && editing;
return (
<Card className="mt-4">
<Card.Header className="text-nowrap d-flex justify-content-between text-capitalize">
{t('title')}
- {!readOnly && editing ? (
+ {showSaveButton ? (
<Button onClick={saveInviteUsers} variant="link" className="p-0">
{t('save', { keyPrefix: 'btns' })}
</Button>
) : null}
- {!readOnly && !editing ? (
+ {showEditButton ? (
<Button
onClick={() => setEditing(true)}
variant="link"