diff --git a/ui/desktop/eslint.config.js b/ui/desktop/eslint.config.js index 87968e311..5e6aa8cac 100644 --- a/ui/desktop/eslint.config.js +++ b/ui/desktop/eslint.config.js @@ -68,6 +68,7 @@ module.exports = [ CustomEvent: 'readonly', HTMLElement: 'readonly', HTMLInputElement: 'readonly', + HTMLSelectElement: 'readonly', HTMLTextAreaElement: 'readonly', HTMLButtonElement: 'readonly', HTMLDivElement: 'readonly', diff --git a/ui/desktop/src/components/ParameterInputModal.tsx b/ui/desktop/src/components/ParameterInputModal.tsx index c3fad93a0..c20a05c82 100644 --- a/ui/desktop/src/components/ParameterInputModal.tsx +++ b/ui/desktop/src/components/ParameterInputModal.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useId, useState, useEffect } from 'react'; import { Parameter } from '../recipe'; import { Button } from './ui/button'; import { defineMessages, useIntl } from '../i18n'; @@ -68,11 +68,12 @@ const ParameterInputModal: React.FC = ({ initialValues, }) => { const intl = useIntl(); + const fieldIdPrefix = useId(); + const fieldId = (key: string): string => `${fieldIdPrefix}-${key}`; const [inputValues, setInputValues] = useState>({}); const [validationErrors, setValidationErrors] = useState>({}); const [showCancelOptions, setShowCancelOptions] = useState(false); - // Pre-fill the form with default values from the recipe and initialValues from deeplink useEffect(() => { const defaultValues: Record = {}; parameters.forEach((param) => { @@ -90,10 +91,8 @@ const ParameterInputModal: React.FC = ({ }; const handleSubmit = (): void => { - // Clear previous validation errors setValidationErrors({}); - // Check if all *required* parameters are filled const requiredParams: Parameter[] = parameters.filter((p) => p.requirement === 'required'); const errors: Record = {}; @@ -113,7 +112,6 @@ const ParameterInputModal: React.FC = ({ }; const handleCancel = (): void => { - // Always show cancel options if recipe has any parameters (required or optional) const hasAnyParams = parameters.length > 0; if (hasAnyParams) { @@ -123,18 +121,9 @@ const ParameterInputModal: React.FC = ({ } }; - const handleCancelOption = (option: 'new-chat' | 'back-to-form'): void => { - if (option === 'new-chat') { - onClose(); - } else { - setShowCancelOptions(false); // Go back to the parameter form - } - }; - return (
{showCancelOptions ? ( - // Cancel options modal

{intl.formatMessage(i18n.cancelRecipeSetup)} @@ -142,25 +131,19 @@ const ParameterInputModal: React.FC = ({

{intl.formatMessage(i18n.whatToDo)}

-

) : ( - // Main parameter form

@@ -171,16 +154,19 @@ const ParameterInputModal: React.FC = ({
{parameters.map((param) => (
-