约束可编辑标题不可为空。

This commit is contained in:
徐涛 2024-12-27 15:45:55 +08:00
parent f0dcb75b50
commit df836a9b6d

View File

@ -1,4 +1,5 @@
import { Icon } from '@iconify/react/dist/iconify.js';
import { isEmpty } from 'lodash-es';
import { useRef, useState } from 'react';
import styles from './EditableTitle.module.css';
@ -16,7 +17,7 @@ export function EditableTitle({ title, onChange }: EditableTitleProps) {
};
const handleSubmit = (data: FormData) => {
const newTitle = data.get('title') as string;
if (newTitle !== title && onChange) {
if (!isEmpty(newTitle) && newTitle !== title) {
onChange?.(newTitle);
}
cancelEdit();