fix: prevent CTRL+Enter save while editor is loading content (#5581)

- Add validation check for loading state before allowing save
- Prevents false "Content, attachment, or file required" error
- Occurs when user presses CTRL+Enter immediately after opening edit mode
- Editor state may still be loading when keyboard shortcut fires

Closes #5581
This commit is contained in:
Steven 2026-02-03 23:55:07 +08:00
parent b4fea8c647
commit 6bb383a4a5
1 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,11 @@ export interface ValidationResult {
export const validationService = {
canSave(state: EditorState): ValidationResult {
// Cannot save while loading initial content
if (state.ui.isLoading.loading) {
return { valid: false, reason: "Loading memo content" };
}
// Must have content, attachment, or local file
if (!state.content.trim() && state.metadata.attachments.length === 0 && state.localFiles.length === 0) {
return { valid: false, reason: "Content, attachment, or file required" };