Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AntD Select with options Clear incorrect work #102

Open
AlexKuznietsov opened this issue Oct 11, 2024 · 0 comments
Open

AntD Select with options Clear incorrect work #102

AlexKuznietsov opened this issue Oct 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@AlexKuznietsov
Copy link

AlexKuznietsov commented Oct 11, 2024

FormItem used with AntD Select component. allowClear is enabled. Field default value is passed as object during useForm initialization.

Clear icon behave in strange way - it works in two steps. On first click - value is set at default. If clicked second time - it cleared to undefined. In case of use standard Form.Item there is no such issue - value is set to default on every click as expected.

Screen.Recording.2024-10-12.021126.mp4

In example below shown both cases

(...)
const CustomerDefault: Customer_B_Regular = {
   _gender: 0,                                     // ?: GenderSet,       //Gender
}
(...)

// weird Clear
<FormItem name="order.customer._gender" label="Gender" control={ control }>

    <Select  
        style={{ textAlign: "start" }}
        allowClear
        placeholder="Please select"
        popupMatchSelectWidth={ false }
        options={[{ value:0, label: 'ND' }, { value:1, label: 'Man' }, { value:2, label: 'Woman' } ]} 
    />

</FormItem>

// Clear works fine
<Form.Item name="order.customer._gender" label="Gender2" >

    <Controller
      name="order.customer._gender"
      control={control}
      render={({ field }) => (
        <Select
            {...field}
            style={{ textAlign: "start" }}
            allowClear
            placeholder="Please select"
            popupMatchSelectWidth={ false }
            options={[{ value:0, label: 'ND' }, { value:1, label: 'Man' }, { value:2, label: 'Woman' } ]} 
        />
      )}
    />

</Form.Item>
@jsun969 jsun969 added the bug Something isn't working label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants