Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: crash on adding a notebook

thecodrra5b21d037308
diff --git a/apps/web/src/components/dialogs/add-notebook-dialog.js b/apps/web/src/components/dialogs/add-notebook-dialog.js
index 804e95bfe..4ec769fe6 100644
--- a/apps/web/src/components/dialogs/add-notebook-dialog.js
+++ b/apps/web/src/components/dialogs/add-notebook-dialog.js
@@ -14,7 +14,7 @@ class AddNotebookDialog extends React.Component {
id = undefined;
deletedTopics = [];
state = {
- topics: [],
+ topics: [{ title: "General" }],
isEditting: false,
editIndex: -1,
};
@@ -119,11 +119,23 @@ class AddNotebookDialog extends React.Component {
negativeButton={{ text: "Cancel", onClick: props.onClose }}
>
<Flex flexDirection="column" sx={{ overflowY: "auto" }}>
- <Field autoFocus required label="Title" name="title" id="title" />
<Field
+ defaultValue={this.title}
+ data-test-id="dialog-nb-name"
+ autoFocus
+ required
+ label="Title"
+ name="title"
+ id="title"
+ onChange={(e) => (this.title = e.target.value)}
+ />
+ <Field
+ data-test-id="dialog-nb-description"
label="Description"
name="description"
id="description"
+ onChange={(e) => (this.description = e.target.value)}
+ defaultValue={this.description}
helpText="Optional"
sx={{ mt: 1 }}
/>
diff --git a/apps/web/src/components/field/index.js b/apps/web/src/components/field/index.js
index 705761089..7ad8e5ae5 100644
--- a/apps/web/src/components/field/index.js
+++ b/apps/web/src/components/field/index.js
@@ -18,6 +18,7 @@ function Field(props) {
onKeyUp,
onChange,
inputRef,
+ defaultValue,
} = props;
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
@@ -40,6 +41,8 @@ function Field(props) {
)}
<Flex mt={1} sx={{ position: "relative" }}>
<Input
+ data-test-id={props["data-test-id"]}
+ defaultValue={defaultValue}
ref={inputRef}
autoFocus={autoFocus}
required={required}