-
Notifications
You must be signed in to change notification settings - Fork 91
fix(carbon): fix time picker initial value #1157
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(carbon): fix time picker initial value #1157
Conversation
A new version (fix) will be released: v3.15.4 [DataDrivenFormsBot] |
Codecov Report
@@ Coverage Diff @@
## master #1157 +/- ##
==========================================
- Coverage 94.89% 94.88% -0.02%
==========================================
Files 209 209
Lines 3567 3579 +12
Branches 1234 1241 +7
==========================================
+ Hits 3385 3396 +11
- Misses 182 183 +1
Continue to review full report at Codecov.
|
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.
Hello,
thank you for this PR.
however, several changes are required:
-
time-picker-base
file is just a styling component with no internal logic, to implement this fix we have to updatetime-picker-date.js
component (string variant is already working well) -
initialLoad
prop is not neccesary, we can just useinitialValue
(resp.input.value
) -
for setting the correct value we can just update the
format
state variable in an init function
before
const [format, selectFormat] = useState('AM');
after
const [format, selectFormat] = useState(() => input.value?.getHours?.() >= 12 ? “PM” : “AM”);
@rvsia I tried out your suggestions and it does not seem to be working. If you would like to test it out I pushed the changes along with the test data I was using in the carbon component mapper sandbox. Not really sure why it is not working initially I was trying out something similar to what your suggestions mentioned but it didn't work which is why I ended up with the complicated code in my first commit. |
closing in favor of #1160 |
Fixes: #1155
Description:
Fixed the AM/PM select initial value for the time picker component.