antoniopresto / antd-mask-input

MIT License
88 stars 35 forks source link

Field blinks masked and then unmasked #72

Open paulorsbrito opened 1 year ago

paulorsbrito commented 1 year ago

The code is as simple as this:

<Edit saveButtonProps={saveButtonProps}>
  <Form {...formProps}>
    <Form.Item
      label="Phone Number"
      name={["phoneNumber"]}
    >
      <MaskedInput mask="(00) 0 0000-0000" />
    </Form.Item>
 </Form>
</Edit>

I'm using @pankod/refine@2.7.8, @refinedev/antd@5.1.0, @refinedev/core@4.1.0, antd-mask-input@2.0.7, antd@5.3.0

paulorsbrito commented 1 year ago

I managed to solve this by passing down an already formatted value, usind getValueProps. I don't think that's the ideal solution but... it is what it is.

pferreirafabricio commented 1 year ago

Same problem here...

pferreirafabricio commented 1 year ago

I managed to solve this by passing down an already formatted value, usind getValueProps. I don't think that's the ideal solution but... it is what it is.

For me the solution was that as well, I did something like this using a ref to the <Form>:

formRef.current?.resetFields();
formRef.current?.setFieldValue('maskValueNameInForm', maskFunction(myValueWithoutMask))

And my form look like this:

<Form
    ref={ref}
    ...
  >
    <Form.Item
      label='Value with mask'
      name='maskValueNameInForm'
    >
      <MaskedInput
        mask='your-mask'
      />
    </Form.Item>
</Form>