diff --git a/apps/comments-ui/src/components/Form.js b/apps/comments-ui/src/components/Form.js
index 6b82ddce94..c4fdc2a2eb 100644
--- a/apps/comments-ui/src/components/Form.js
+++ b/apps/comments-ui/src/components/Form.js
@@ -302,26 +302,13 @@ const Form = (props) => {
editor.commands.focus();
};
- const handleAddBoth = (event) => {
+ const handleShowDialog = (event, options) => {
event.preventDefault();
setPreventClosing(true);
dispatchAction('openPopup', {
type: 'addDetailsDialog',
- callback: () => {
- editor?.commands.focus();
- setPreventClosing(false);
- }
- });
- };
-
- const handleAddBio = (event) => {
- event.preventDefault();
- setPreventClosing(true);
-
- dispatchAction('openPopup', {
- type: 'addDetailsDialog',
- bioOnly: true,
+ bioAutofocus: options.bioAutofocus ?? false,
callback: () => {
editor?.commands.focus();
setPreventClosing(false);
@@ -422,9 +409,21 @@ const Form = (props) => {
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
-
-
-
+
+
+
diff --git a/apps/comments-ui/src/components/modals/AddDetailsDialog.js b/apps/comments-ui/src/components/modals/AddDetailsDialog.js
index 3d2013c09a..dc146dab0b 100644
--- a/apps/comments-ui/src/components/modals/AddDetailsDialog.js
+++ b/apps/comments-ui/src/components/modals/AddDetailsDialog.js
@@ -26,37 +26,27 @@ const AddNameDialog = (props) => {
};
const submit = async () => {
- // When it's both name and bio
- if (!props.bioOnly) {
- if (name.trim() !== '') {
- await dispatchAction('updateMember', {
- name,
- bio
- });
- close(true);
- } else {
- setError({name: 'Enter your name'});
- setName('');
- inputNameRef.current?.focus();
- }
- // When it's only bio
- } else {
+ if (name.trim() !== '') {
await dispatchAction('updateMember', {
+ name,
bio
});
-
close(true);
+ } else {
+ setError({name: 'Enter your name'});
+ setName('');
+ inputNameRef.current?.focus();
}
};
// using breaks transitions in browsers. So we need to use a timer
useEffect(() => {
const timer = setTimeout(() => {
- if (!props.bioOnly) {
- inputNameRef.current?.focus();
- } else {
+ if (props.bioAutofocus) {
inputBioRef.current?.focus();
- }
+ } else {
+ inputNameRef.current?.focus();
+ }
}, 200);
return () => {
@@ -69,43 +59,39 @@ const AddNameDialog = (props) => {
Add context to your comments
For a healthy discussion, let other members know who you are when commenting.
- {!props.bioOnly &&
- <>
-
-
-
- {error.name}
-
-
- {
- setName(e.target.value);
- }}
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- setName(e.target.value);
- submit();
- }
- }}
- maxLength="64"
- />
- >
- }
+
+
+
+ {error.name}
+
+
+ {
+ setName(e.target.value);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ setName(e.target.value);
+ submit();
+ }
+ }}
+ maxLength="64"
+ />
{bioCharsLeft} characters left