Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

fix: make sure to create picker before calling update #5

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

ghiscoding
Copy link
Owner

@ghiscoding ghiscoding commented Jun 21, 2024

  • calling .update() before the date picker is created was causing the input to be override as the new picker element and was also causing leakage when clicking the input because at that point 2 elements were now assigned as the picker container (input & new picker in the body)
  • move the createCalendarToInput as a separate and exported function so that we can call it at the start of the .update() if the picker hasn't been created yet.
  • the only thing that I'm not entirely sure is the cleanup thing, if we create the picker outside of the handleInput, then we don't have access to that cleanup array, however I couldn't find how this cleanup is being called, so it might ok to leave it

below is the bug that was found, you can see the input being reassigned as the new picker (and the correct picker is not being created in the body because it thinks the input is the picker)

bug

ref codesandbox

image

brave_Yjlsbl4Vfw

after fix

now we can see that when we click the set date button, it will initialize (create) the picker in body and leave the input untouched as it should be

brave_WxJ4vQSZqF

- calling `.update()` before the date picker is created was causing the input to be override as the new picker element and was also causing leakage when clicking the input because at that point 2 elements were now assigned as the picker container (input & new picker in the body)
@ghiscoding ghiscoding merged commit 3bb1df2 into main Jun 21, 2024
6 checks passed
@ghiscoding ghiscoding deleted the bugfix/init-picker-before-update branch June 21, 2024 19:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant