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
This commit is contained in:
Danielle Maywood
2025-10-17 11:24:37 +01:00
committed by GitHub
parent dc6e50d6b7
commit a1fa5c8c96
2 changed files with 32 additions and 1 deletions
@@ -72,6 +72,37 @@ export const ReadOnlyPresetPrompt: Story = {
},
};
export const SubmitEnabledWhenPromptNotEmpty: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const prompt = await canvas.findByLabelText(/prompt/i);
await userEvent.type(prompt, MockNewTaskData.prompt);
const submitButton = canvas.getByRole("button", { name: /run task/i });
expect(submitButton).toBeEnabled();
},
};
export const SubmitDisabledWhenPromptEmpty: Story = {
play: async ({ canvasElement, step }) => {
const canvas = within(canvasElement);
await step("No prompt", async () => {
const submitButton = canvas.getByRole("button", { name: /run task/i });
expect(submitButton).toBeDisabled();
});
await step("Whitespace prompt", async () => {
const prompt = await canvas.findByLabelText(/prompt/i);
await userEvent.type(prompt, " ");
const submitButton = canvas.getByRole("button", { name: /run task/i });
expect(submitButton).toBeDisabled();
});
},
};
export const OnSuccess: Story = {
decorators: [withGlobalSnackbar],
parameters: {
@@ -368,7 +368,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
<Button
size="icon"
type="submit"
disabled={isMissingExternalAuth}
disabled={prompt.trim().length === 0 || isMissingExternalAuth}
className="rounded-full disabled:bg-surface-invert-primary disabled:opacity-70"
>
<Spinner