Setup slugify and fix nanoid issues
This commit is contained in:
parent
1f577fc410
commit
27d41aaeed
19 changed files with 558 additions and 134 deletions
|
|
@ -39,6 +39,7 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
|||
project,
|
||||
areas,
|
||||
}) => {
|
||||
const [modalJustOpened, setModalJustOpened] = useState(false);
|
||||
const [formData, setFormData] = useState<Project>(
|
||||
project || {
|
||||
name: '',
|
||||
|
|
@ -89,9 +90,15 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
|||
// Load tags when modal opens and auto-focus on the name input
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
// Load tags if not loaded yet
|
||||
// Load tags with a delay to avoid conflicts with modal state
|
||||
if (!tagsStore.hasLoaded && !tagsStore.isLoading) {
|
||||
tagsStore.loadTags();
|
||||
// Delay tag loading to avoid immediate state conflicts
|
||||
setTimeout(() => {
|
||||
if (isOpen) {
|
||||
// Only load if modal is still open
|
||||
tagsStore.loadTags();
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
setTimeout(() => {
|
||||
nameInputRef.current?.focus();
|
||||
|
|
@ -234,6 +241,17 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
|||
}));
|
||||
}, []);
|
||||
|
||||
// Track when modal opens to prevent immediate backdrop clicks
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setModalJustOpened(true);
|
||||
const timer = setTimeout(() => {
|
||||
setModalJustOpened(false);
|
||||
}, 200); // Prevent backdrop clicks for 200ms after opening
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
const handleDueDateChange = (value: string) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
|
|
@ -434,7 +452,8 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
|||
}`}
|
||||
onClick={(e) => {
|
||||
// Close modal when clicking on backdrop, but not on the modal content
|
||||
if (e.target === e.currentTarget) {
|
||||
// Also prevent immediate closes after modal opens
|
||||
if (e.target === e.currentTarget && !modalJustOpened) {
|
||||
handleClose();
|
||||
}
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue