-
Notifications
You must be signed in to change notification settings - Fork 62
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
fix(date): update onChange to handle null value when date input is cleared #1125
fix(date): update onChange to handle null value when date input is cleared #1125
Conversation
@@ -9,7 +9,7 @@ type Props = Omit<ComponentPropsWithRef<'input'>, 'value'> & { | |||
value?: Date; | |||
}; | |||
|
|||
const Date = forwardRef<HTMLInputElement, Props>( | |||
const CustomDate = forwardRef<HTMLInputElement, Props>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: je pense que tu peux laisser <Date />
Quand tu l'importeras, si tu es embêté avec un new Date, tu peux l'importer comme ça :
import { Date as DateComponent } from '.....'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dc22f13
to
54932a6
Compare
const inputElement = getByDisplayValue('2024-03-04'); | ||
|
||
expect(inputElement).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vu que tu fais un getBy..., si l'élément n'existe pas il va retourner une erreur.
Tu n'as donc pas besoin de faire expect(inputElement).toBeInTheDocument();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectivement, du coup j'ai enlevé ce test
); | ||
const inputElement = getByLabelText('Date:') as HTMLInputElement; | ||
|
||
fireEvent.change(inputElement, { target: { value: '2024-03-05' } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est mieux d'utiliser userEvent, ça rapproche plus d'un comportement utilisateur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
const inputElement = getByLabelText('Date:') as HTMLInputElement; | ||
|
||
expect(inputElement).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vu que tu fais un getBy..., si l'élément n'existe pas il va retourner une erreur.
Tu n'as donc pas besoin de faire expect(inputElement).toBeInTheDocument();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectivement, du coup j'ai enlevé ce test
|
||
expect(inputElement).toBeInTheDocument(); | ||
|
||
fireEvent.change(inputElement, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est mieux d'utiliser userEvent, ça rapproche plus d'un comportement utilisateur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
const labelElement = getByLabelText('Date début'); | ||
expect(labelElement).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vu que tu fais un getBy..., si l'élément n'existe pas il va retourner une erreur.
Tu n'as donc pas besoin de faire expect(labelElement).toBeInTheDocument();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectivement, du coup j'ai enlevé ce test
54932a6
to
b0136e0
Compare
…null value when date input is cleared
b0136e0
to
ff6f85e
Compare
@ElammariYoussef des news sur le build failed actuel ? |
Non, on a pas encore trouvé, c'est une erreur générale lors de la génération des storybooks dans le projet |
Je clôture la PR car je n'arrive plus à relancer la build, en la recréant il se peut que cela fonctionne à nouveau. |
Related issue
Reference to the issue
#1002
Description of the issue
The date input call the onChange prop even when the "clear" native behavior is clicked. The component will send a null value.
Important
Before creating a pull request run unit tests