Skip to content

fix(date-picker): ensure one datepicker is open #618

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

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Conversation

hebernardEquisoft
Copy link
Contributor

@hebernardEquisoft hebernardEquisoft commented Oct 16, 2023

DS-889

Description

Auparavant, lorsqu'un utilisateur ouvrait le calendrier d'un composant Datepicker puis cliquait sur le bouton d'un autre composant Datepicker, les deux calendriers restaient ouverts simultanément. Cette PR corrige ce comportement afin qu'un seul calendrier puisse être ouvert à la fois.

Ajout d'un événement personnalisé pour fermer les autres instances de Datepicker lors de l'ouverture d'un nouveau.
À l'aide d'un listener d'événements sur le document permettant d'écouter cet événement et fermer le Datepicker actuellement ouvert si nécessaire.

Tests fonctionnels

  • Valider le bon fonctionnement du datepicker
  • Valider qu'il ne peut y avoir plus d'un datepicker ouvert à la fois

@hebernardEquisoft hebernardEquisoft requested a review from a team as a code owner October 16, 2023 17:27
Copy link
Contributor

@meriouma meriouma left a comment

Choose a reason for hiding this comment

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

Je pense qu'on peut corriger le problème plus simplement, en enlevant le event.stopPropagation() du handleCalendarButtonMouseDown, et d'appeler ce handler sur le onMouseUp plutôt et non le onMouseDown. Je pense que ça corrigerait le problème sans briser d'autres comportements.

Copy link
Contributor

@meriouma meriouma left a comment

Choose a reason for hiding this comment

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

Ah ben c'est encore plus simple finalement, même pas besoin de changer d'event handler on dirait.

if (
dateInputRef.current
&& calendarButtonRef.current
&& eventIsInside(event as unknown as Event, calendarButtonRef.current)
Copy link
Contributor

Choose a reason for hiding this comment

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

Quand j'ai essayé il était null. C'est probablement un event lancé manuellement par la lib

@pylafleur
Copy link
Contributor

pylafleur commented Oct 18, 2023

Quand j'ai essayé il était null. C'est probablement un event lancé manuellement par la lib

Ouais, j'ai retiré mon commentaire avant de voir que t'avais répondu mais t'as raison, le typage doit pas être bon parce que c'est réellement un event natif qui est reçu actuellement par la fonction. All good!

@hebernardEquisoft hebernardEquisoft merged commit 712e42e into master Oct 18, 2023
@hebernardEquisoft hebernardEquisoft deleted the dev/DS-889 branch October 18, 2023 20:55
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.

4 participants