Skip to content

Commit 2c4acf8

Browse files
committed
fixup: nameTrimmed
1 parent 88cf68a commit 2c4acf8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

gui/src/renderer/components/select-location/CustomListDialogs.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,15 @@ export function EditListDialog(props: EditListProps) {
147147
const { updateCustomList } = useAppContext();
148148

149149
const [newName, setNewName] = useState(props.list.name);
150-
const newNameValid = newName.trim() !== '';
150+
const newNameTrimmed = newName.trim()
151+
const newNameValid = newNameTrimmed !== '';
151152
const [error, setError, unsetError] = useBoolean();
152153

153154
// Update name in list and save it.
154155
const save = useCallback(async () => {
155156
if (newNameValid) {
156157
try {
157-
const updatedList = { ...props.list, name: newName.trim() };
158+
const updatedList = { ...props.list, name: newNameTrimmed };
158159
const result = await updateCustomList(updatedList);
159160
if (result && result.type === 'name already exists') {
160161
setError();

gui/src/renderer/components/select-location/CustomLists.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ interface AddListFormProps {
123123

124124
function AddListForm(props: AddListFormProps) {
125125
const [name, setName] = useState('');
126-
const nameValid = name.trim() !== '';
126+
const nameTrimmed = name.trim()
127+
const nameValid = nameTrimmed !== '';
127128
const [error, setError, unsetError] = useBoolean();
128129
const containerRef = useStyledRef<HTMLDivElement>();
129130
const inputRef = useStyledRef<HTMLInputElement>();
@@ -137,7 +138,7 @@ function AddListForm(props: AddListFormProps) {
137138
const createList = useCallback(async () => {
138139
if (nameValid) {
139140
try {
140-
const result = await props.onCreateList(name.trim());
141+
const result = await props.onCreateList(nameTrimmed);
141142
if (result) {
142143
setError();
143144
}

0 commit comments

Comments
 (0)