Closed MiroslavPetrik closed 6 months ago
Run & review this pull request in StackBlitz Codeflow.
The latest updates on your projects. Learn more about Vercel for Git βοΈ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
flowbite-react | β Ready (Inspect) | Visit Preview | π¬ Add feedback | Mar 15, 2024 8:44am |
This update significantly enhances the Datepicker
component by integrating forwardRef
and useImperativeHandle
, allowing for direct manipulation via a ref
. It introduces a DatepickerRef
interface, offering focus
and clear
methods for external control. Furthermore, it improves internal functions and beefs up testing with new utilities and tests for the added methods, ensuring the componentβs robustness and flexibility in handling user interactions.
File | Change Summary |
---|---|
src/components/Datepicker/Datepicker.tsx |
- Refactored to use forwardRef and useImperativeHandle - Exposed DatepickerRef interface with focus and clear methods- Adjusted internal functions for better control - Added tests for focusing input and clearing value using ref.current |
src/components/Datepicker/Datepicker.spec.tsx |
- Added tests for focusing input and clearing value using ref.current |
Objective | Addressed | Explanation |
---|---|---|
Enable forwarding of ref to the Datepicker component (#1299) |
β | |
Implement a programmatic API that exposes methods to the ref object using useImperativeHandle (#1299) |
β | |
Address the limitation of the Datepicker being uncontrolled and only accepting defaultValue but not the value prop (#1299) |
β | |
Implement a clear() method to reset the Datepicker value to the default (#1299) |
β | |
Allow the Datepicker to accept a ref for focusing the input programmatically (#1299) |
β |
π°β¨π β¨π°
A hop, a skip, in the code we dip,
To tweak and fix, with magic tricks.
Now with a tap, or a gentle click,
Focus, clear, all so slick.
In fields of dates, our choices stick.
π°β¨π β¨π°
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 95.53%. Comparing base (
7461173
) to head (c8e46ba
). Report is 201 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Closes #1299 (possibly #1039)
Summarize the changes made and the motivation behind them.
Enhanced the Datepicker component to expose
clear()
andfocus()
ref methods. This is required when datepicker value is in controlled mode.Reference related issues using
#
followed by the issue number.Closes #1299 and (possibly #1039)
If there are breaking API changes - like adding or removing props, or changing the structure of the theme - describe them, and provide steps to update existing code.
No breaking changes.
Summary by CodeRabbit
focus
andclear
methods.