Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1fa5c8

Browse files
fix(site): disable task prompt submit button when prompt empty (#20357)
Disable the submit button by default in the task creation form, it is only enabled once the prompt field is non empty
1 parentdc6e50d commita1fa5c8

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

‎site/src/modules/tasks/TaskPrompt/TaskPrompt.stories.tsx‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,37 @@ export const ReadOnlyPresetPrompt: Story = {
7272
},
7373
};
7474

75+
exportconstSubmitEnabledWhenPromptNotEmpty:Story={
76+
play:async({ canvasElement})=>{
77+
constcanvas=within(canvasElement);
78+
79+
constprompt=awaitcanvas.findByLabelText(/prompt/i);
80+
awaituserEvent.type(prompt,MockNewTaskData.prompt);
81+
82+
constsubmitButton=canvas.getByRole("button",{name:/runtask/i});
83+
expect(submitButton).toBeEnabled();
84+
},
85+
};
86+
87+
exportconstSubmitDisabledWhenPromptEmpty:Story={
88+
play:async({ canvasElement, step})=>{
89+
constcanvas=within(canvasElement);
90+
91+
awaitstep("No prompt",async()=>{
92+
constsubmitButton=canvas.getByRole("button",{name:/runtask/i});
93+
expect(submitButton).toBeDisabled();
94+
});
95+
96+
awaitstep("Whitespace prompt",async()=>{
97+
constprompt=awaitcanvas.findByLabelText(/prompt/i);
98+
awaituserEvent.type(prompt," ");
99+
100+
constsubmitButton=canvas.getByRole("button",{name:/runtask/i});
101+
expect(submitButton).toBeDisabled();
102+
});
103+
},
104+
};
105+
75106
exportconstOnSuccess:Story={
76107
decorators:[withGlobalSnackbar],
77108
parameters:{

‎site/src/modules/tasks/TaskPrompt/TaskPrompt.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
368368
<Button
369369
size="icon"
370370
type="submit"
371-
disabled={isMissingExternalAuth}
371+
disabled={prompt.trim().length===0||isMissingExternalAuth}
372372
className="rounded-full disabled:bg-surface-invert-primary disabled:opacity-70"
373373
>
374374
<Spinner

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp