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

fix(datepicker): ensure flatpickr instance is crated after lazy input resolves #12969

Merged
merged 6 commits into from
Jan 12, 2023

Conversation

tay1orjones
Copy link
Member

@tay1orjones tay1orjones commented Jan 11, 2023

Closes #10692

If the DatePicker was brought in via React.lazy, the ref assigned to the start input was not being updated after the component resolved. This caused the flatpickr instance to never be assigned to the input, so the calendar would never show.

Changelog

Changed

  • update datepicker to use useCallback instead of useRef, store the status of the ref in state, and use it to trigger the existing useEffect after react.lazy resolves

Testing / Reviewing

  • Check out the simple datepicker story, it should function normally. I've modified it to use react.lazy
  • Don't merge this PR until we've reverted the story to it's original state. Done

… resolves

>
>
Co-authored-by: TJ EGAN tw15egan@gmail.com
@netlify
Copy link

netlify bot commented Jan 11, 2023

Deploy Preview for carbon-components-react ready!

Name Link
🔨 Latest commit cbcf902
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/63c06753a1b619000c03002d
😎 Deploy Preview https://deploy-preview-12969--carbon-components-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Jan 11, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit cbcf902
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/63c0675337b07800084dbf93
😎 Deploy Preview https://deploy-preview-12969--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@tay1orjones tay1orjones self-assigned this Jan 12, 2023
Copy link
Collaborator

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

😍 LGTM!

@kodiakhq kodiakhq bot merged commit 44c238a into carbon-design-system:main Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Bug]: DatePicker and DatePicker input are not clickable when loaded with React.lazy
3 participants