-
Notifications
You must be signed in to change notification settings - Fork 0
fix: increment day when button is clicked before input focus #97
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
Conversation
WalkthroughThe update modifies the internal logic of the date picker component's JavaScript file. It introduces an event listener for the input element's focus event to track when the input is focused. In the method handling button clicks for incrementing date parts, the logic now distinguishes between focused and unfocused states: if the input is focused, the incremented part is determined by the cursor position; if unfocused, the day component is incremented by default. No changes are made to the public API or method signatures. Changes
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/main/resources/META-INF/frontend/fc-date-picker/fc-date-picker.js (2)
73-73
: Consider adding a blur event listenerYou've added a focus event listener that sets
__focused
to true, but there's no corresponding blur listener to reset it to false. If the intention is to only handle the first-time focus differently, then this is fine. Otherwise, consider adding a blur event listener:this.inputElement.addEventListener('focus', ()=>this.__focused=true); +this.inputElement.addEventListener('blur', ()=>this.__focused=false);
161-171
: The fix properly handles unfocused input stateThe change correctly implements the desired behavior of incrementing the day part when the button is clicked before input focus. This provides a more intuitive default behavior.
One minor suggestion for improved readability:
} else { part = 'D'; - // find the index where D start + // Count how many non-digit characters appear before 'D' in the format string index = 0; for (let i=0;i<format.length && format[i]!=part;i++) { if (!format[i].match(/[0-9]/)) index++; } }
Summary by CodeRabbit