Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions frontend/src/components/dialogs/tasks/TaskFormDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const TaskFormDialogImpl = NiceModal.create<TaskFormDialogProps>((props) => {
};

const validator = (value: TaskFormValues): string | undefined => {
if (!value.title.trim().length) return 'need title';
// Title is validated in a field level validator
if (
value.autoStart &&
!forceCreateOnlyRef.current &&
Expand All @@ -222,9 +222,6 @@ const TaskFormDialogImpl = NiceModal.create<TaskFormDialogProps>((props) => {
defaultValues: defaultValues,
onSubmit: handleSubmit,
validators: {
// we use an onMount validator so that the primary action button can
// enable/disable itself based on `canSubmit`
onMount: ({ value }) => validator(value),
onChange: ({ value }) => validator(value),
},
});
Expand Down Expand Up @@ -320,11 +317,6 @@ const TaskFormDialogImpl = NiceModal.create<TaskFormDialogProps>((props) => {
preventDefault: true,
});

const canSubmitAlt = useStore(
form.store,
(state) => state.values.title.trim().length > 0 && !state.isSubmitting
);

const handleSubmitCreateOnly = useCallback(() => {
forceCreateOnlyRef.current = true;
const promise = form.handleSubmit();
Expand All @@ -334,7 +326,7 @@ const TaskFormDialogImpl = NiceModal.create<TaskFormDialogProps>((props) => {
}, [form]);

useKeySubmitTaskAlt(handleSubmitCreateOnly, {
enabled: modal.visible && canSubmitAlt && !showDiscardWarning,
enabled: shortcutsEnabled,
Copy link
Collaborator Author

@britannio britannio Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shortcut to create a task without starting it should work even if the form is in an invalid state (missing title).

scope: Scope.DIALOG,
enableOnFormTags: ['input', 'INPUT', 'textarea', 'TEXTAREA'],
preventDefault: true,
Expand Down Expand Up @@ -408,17 +400,32 @@ const TaskFormDialogImpl = NiceModal.create<TaskFormDialogProps>((props) => {

{/* Title */}
<div className="flex-none pr-8 pt-3">
<form.Field name="title">
<form.Field
name="title"
validators={{
onSubmit: ({ value }) =>
!value.trim().length
? t('taskFormDialog.errors.titleRequired')
: undefined,
}}
>
{(field) => (
<Input
id="task-title"
value={field.state.value}
onChange={(e) => field.handleChange(e.target.value)}
placeholder={t('taskFormDialog.titlePlaceholder')}
className="text-lg font-medium border-none shadow-none px-0 placeholder:text-muted-foreground/60 focus-visible:ring-0"
disabled={isSubmitting}
autoFocus
/>
<>
<Input
id="task-title"
value={field.state.value}
onChange={(e) => field.handleChange(e.target.value)}
placeholder={t('taskFormDialog.titlePlaceholder')}
className="text-xl font-medium border-none shadow-none px-0 placeholder:text-muted-foreground/60 focus-visible:ring-0"
disabled={isSubmitting}
autoFocus
/>
{!field.state.meta.isValid && (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we show the 'Title is required' warning if validation fails during submission.

<em role="alert" className="text-destructive">
{field.state.meta.errors.join(', ')}
</em>
)}
</>
)}
</form.Field>
</div>
Expand Down Expand Up @@ -594,26 +601,23 @@ const TaskFormDialogImpl = NiceModal.create<TaskFormDialogProps>((props) => {
{/* Create/Start/Update button*/}
<form.Subscribe
selector={(state) => ({
canSubmit: state.canSubmit,
isSubmitting: state.isSubmitting,
values: state.values,
autoStart: state.values.autoStart,
})}
>
{({ canSubmit, isSubmitting, values }) => {
{({ isSubmitting, autoStart }) => {
const buttonText = editMode
? isSubmitting
? t('taskFormDialog.updating')
: t('taskFormDialog.updateTask')
: isSubmitting
? values.autoStart
? autoStart
? t('taskFormDialog.starting')
: t('taskFormDialog.creating')
: t('taskFormDialog.create');

return (
<Button onClick={form.handleSubmit} disabled={!canSubmit}>
{buttonText}
</Button>
<Button onClick={form.handleSubmit}>{buttonText}</Button>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the button is always enabled now, rather than only when the form is valid.

);
}}
</form.Subscribe>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/i18n/locales/en/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@
"starting": "Starting...",
"creating": "Creating...",
"create": "Create",
"errors": {
"titleRequired": "Title is required"
},
"discardDialog": {
"title": "Discard unsaved changes?",
"description": "You have unsaved changes. Are you sure you want to discard them?",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/i18n/locales/es/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@
"starting": "Iniciando...",
"creating": "Creando...",
"create": "Crear",
"errors": {
"titleRequired": "El título es obligatorio"
},
"discardDialog": {
"title": "¿Descartar cambios sin guardar?",
"description": "Tienes cambios sin guardar. ¿Estás seguro de que deseas descartarlos?",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/i18n/locales/ja/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@
"starting": "開始中...",
"creating": "作成中...",
"create": "作成",
"errors": {
"titleRequired": "タイトルは必須です"
},
"discardDialog": {
"title": "未保存の変更を破棄しますか?",
"description": "未保存の変更があります。本当に破棄してもよろしいですか?",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/i18n/locales/ko/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@
"starting": "시작 중...",
"creating": "만드는 중...",
"create": "만들기",
"errors": {
"titleRequired": "제목은 필수입니다"
},
"discardDialog": {
"title": "저장하지 않은 변경사항을 버리시겠습니까?",
"description": "저장하지 않은 변경사항이 있습니다. 정말 버리시겠습니까?",
Expand Down