fix(datepicker): sync hidden alt field on manual date entry - #3273
Open
faisalahammad wants to merge 1 commit into
Open
fix(datepicker): sync hidden alt field on manual date entry#3273faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
The datepicker keyup handler only cleared the hidden alt field on invalid input, never re-synced it after a valid manual typed date. Under non-US WP date formats, manually editing a date caused the hidden m/d/Y field to stay stale or empty, leading to mis-parsed restriction dates on the front end. Parse against the picker's bound format and write the alt-format formatted value back to the hidden field on a valid parse; leave the existing clear-on-invalid behavior intact. Fixes gocodebox#2448
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2448
Restores the datepicker hidden alt-field contract from #2884: the hidden field that gets submitted should be the authoritative, unambiguous
m/d/Yvalue regardless of how the date was entered (calendar picker or manual typing).Prior to this fix, the keyup handler in
bind_datepickeronly cleared the alt field on unparseable input. A user manually typing a valid date into the visible site-format field left the hidden field stale or untouched, so the stored meta could be an older m/d/Y entry or an empty value, and the front-end parsed it under PHP's USm/d/Yassumption regardless of the configureddate_format, causing mis-rendered restriction dates.After: on a valid parse the handler writes
$.datepicker.formatDate(altFormat, date)into the hidden alt field. Existing clear-on-invalid behavior is preserved. Picker selection path is unchanged.How has this been tested?
d/m/Y: typed06/01/2023(meaning Jan 6) into the course Enrollment Start Date field, saved, confirmed front-end does not show "Enrollment in this course opens on..." for a past date.d/m/Y, confirmed round-trip is correct (idempotent with keyup sync).bind_editablesdatetime branch) and the reporting/analytics template date inputs have nodata-alt-field, so the early-return branch makes the new logic a no-op there.Local env: WordPress 6.x, LifterLMS trunk-aligned
devbranch. JS lint (npm run lint:js) does not currently coverassets/js/private/, so no automated JS style run is possible against this file in this environment.Screenshots
N/A - admin UI behavior change is not visually distinct.
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
.changelogs/fix-enrollment-date-manual-entry-parse.yml.