Repository navigation
Conversation
|
@alondmnt, @nishantwrp, Kindly review this PR |
| // Use type="text" instead of type="date" to bypass Chromium's OS-locale | ||
| // date picker, which ignores Joplin's date format setting (issue #112). | ||
| // The placeholder shows the user's configured format as a hint. | ||
| return `<input name="${encode(this.name)}" type="text" placeholder="${encode(this.dateFormat)}" pattern="\\d{4}-\\d{2}-\\d{2}"></input>`; |
There was a problem hiding this comment.
isn't there an option to give locale to <input type="date">?
There was a problem hiding this comment.
Thanks for the question, I did look into this — unfortunately, Chromium ignores the lang attribute and all HTML locale hints for . The display format is controlled purely by the OS locale, not the page settings. This is a known limitation even in Electron.
Switching to type="text" with a placeholder showing the user's Joplin date format was the only reliable workaround I found. Happy to explore any other approach if you have one in mind!
There was a problem hiding this comment.
I see. I think text would be inconvenient for the users when compared to a native date-picker.
Maybe, we can explore some small custom date picker component (maybe https://www.npmjs.com/package/react-datepicker). Maybe need some additional work to comply with joplin theming but maybe that is something that can be done in follow-up.
3d1d498 to
9778666
Compare
|
Updated! I've replaced the type="text" workaround with a flatpickr custom date picker. It respects the user's Joplin date format, shows a native-feeling calendar UI, supports both clicking and typing, and adapts to Joplin's theme. |
joplin#112) - Replaced <input type="date"> with a flatpickr-powered custom date picker - flatpickr is initialized in datepicker.js using the user's configured Joplin date format (e.g. YYYY-MM-DD), converted from moment.js to flatpickr tokens - Added a year dropdown so users can jump to any year quickly (±10 years) - The calendar theme is adapted to Joplin's dark/light CSS variables - Date format is injected into each DateCustomVariable via setDateFormat() called from parser.ts before the dialog is rendered
9778666 to
3681032
Compare
| overflow: auto; | ||
| } | ||
|
|
||
| /* ── Flatpickr: make the calendar fit the dialog and match Joplin theme ── */ |
There was a problem hiding this comment.
can you move these to src/views/flatpicker-overrides.css
| } | ||
|
|
||
| th, td { | ||
| th, |
There was a problem hiding this comment.
can you revert these linting changes, helps keep the diff small and focus on whats actually changed
| // so the placeholder matches their configured format (fixes issue #112). | ||
| for (const variable of Object.values(variableObjects)) { | ||
| if (variable instanceof DateCustomVariable) { | ||
| variable.setDateFormat(this.utils.getDateFormat()); |
There was a problem hiding this comment.
why can't this be done inside "src/variables/types/date.ts"?
|
Hi @sh1vam31, friendly reminder on the outstanding review comments: the CSS split, linting revert, and moving the format injection into date.ts. Let us know if you need any help. |
|
Hi @nishantwrp and @alondmnt, thanks for the feedback. I've updated the PR and addressed all review comments: CSS Split: Moved Flatpickr-specific styles into Linting: Reverted the unrelated Format Injection: Refactored the code so Conflicts: Merged Let me know if it looks good. |
|
Thanks @sh1vam31! What should happen when the date field is left empty, or someone types something that doesn't match the format? As it stands processInput throws, so the whole template fails with the parsing error and the dialog input is lost. Try leaving the field blank, or typing the date in a wrong format, and see what you get. The old native input never put the plugin in that state, so it's worth handling deliberately. flatpickr is added to package.json, but the code uses the copied flatpickr.min.* files in src/views. Could you use one or the other? Also, I believe that the PR description needs an update. |
|
Hi @alondmnt, thanks for the review. I've updated the PR based on your feedback:
|
Fixes #112 — Template dialog UI should respect the date locale settings
Description
The native HTML5
<input type="date">in Chromium (used by Electron/Joplin) hardcodes its internal representation and ignores Joplin's Tools → Options → Date format setting. Furthermore, native date inputs cannot be themed consistently to match Joplin's dark/light modes and lack quick year navigation.Fix
--joplin-background-color,--joplin-color, etc.) insrc/views/flatpicker-overrides.css.<select>dropdown (±10 years) for easier navigation.YYYY-MM-DD) are normalized into the user's configured format.package.jsonand copied directly fromnode_modulesinto the distribution bundle via Webpack.