Skip to content

fix: keep free-solo dropdown values#6594

Open
cyphercodes wants to merge 1 commit into
FlowiseAI:mainfrom
cyphercodes:cyphercodes/6590-free-solo-azure-model
Open

fix: keep free-solo dropdown values#6594
cyphercodes wants to merge 1 commit into
FlowiseAI:mainfrom
cyphercodes:cyphercodes/6590-free-solo-azure-model

Conversation

@cyphercodes

Copy link
Copy Markdown

Description

Fixes #6590.

Allows free-solo dropdown fields to keep and submit typed values that are not present in the predefined option list. This lets Azure OpenAI deployment/model names such as custom gpt-5.4-* deployments remain selectable instead of being reset to an empty value.

Tests

  • pnpm --filter flowise-ui test -- dropdownUtils.test.js --runInBand
  • NODE_OPTIONS=--max-old-space-size=4096 pnpm --filter flowise-ui build
  • pnpm exec eslint packages/ui/src/ui-component/dropdown/Dropdown.jsx packages/ui/src/ui-component/dropdown/AsyncDropdown.jsx packages/ui/src/ui-component/dropdown/dropdownUtils.js packages/ui/src/ui-component/dropdown/dropdownUtils.test.js
  • git diff --check HEAD^..HEAD

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the AsyncDropdown and Dropdown components by extracting common helper functions into a new utility file dropdownUtils.js and adding corresponding unit tests. The review feedback highlights a potential bug in isOptionEqualToValue where empty values and options with missing names could incorrectly evaluate to equal, suggesting a fix and an accompanying test case. Additionally, it recommends using loose equality (== null) for nullish checks in isEmptyDropdownValue to adhere to standard JavaScript idioms.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

return selection?.name ?? ''
}

export const isOptionEqualToValue = (option, value) => getOptionName(option) === getOptionName(value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

If value is empty (e.g., '' or null when cleared) and an option does not have a name property (or has an empty name), isOptionEqualToValue will return true because both getOptionName(option) and getOptionName(value) evaluate to ''. This causes MUI Autocomplete to incorrectly treat that option as selected. To prevent this, we should ensure that the option name is truthy before performing the equality check.

Suggested change
export const isOptionEqualToValue = (option, value) => getOptionName(option) === getOptionName(value)
export const isOptionEqualToValue = (option, value) => {
const optionName = getOptionName(option)
const valueName = getOptionName(value)
return !!optionName && optionName === valueName
}

return option?.label ?? option?.name ?? ''
}

export const isEmptyDropdownValue = (value) => value === undefined || value === null || value === '' || value === DEFAULT_DROPDOWN_VALUE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the repository's general rules, loose equality (== null) should be used as a standard idiom for a 'nullish' check that covers both null and undefined in JavaScript/TypeScript.

Suggested change
export const isEmptyDropdownValue = (value) => value === undefined || value === null || value === '' || value === DEFAULT_DROPDOWN_VALUE
export const isEmptyDropdownValue = (value) => value == null || value === '' || value === DEFAULT_DROPDOWN_VALUE
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

Comment on lines +44 to +47
it('handles option labels and equality for string values', () => {
expect(getOptionLabel('gpt-5.4-nano-suporte-juridico')).toBe('gpt-5.4-nano-suporte-juridico')
expect(isOptionEqualToValue(options[0], 'gpt-5')).toBe(true)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Add a test case to verify that isOptionEqualToValue correctly returns false when comparing an option with a missing/empty name against an empty value.

    it('handles option labels and equality for string values', () => {
        expect(getOptionLabel('gpt-5.4-nano-suporte-juridico')).toBe('gpt-5.4-nano-suporte-juridico')
        expect(isOptionEqualToValue(options[0], 'gpt-5')).toBe(true)
        expect(isOptionEqualToValue({ label: 'Select' }, '')).toBe(false)
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure OpenAI: custom/deployed model names not selectable in "Model Name" dropdown

1 participant