Skip to content
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 for the hidden and displayed datepicker fields not holding the cu… #2766

Conversation

btsdev
Copy link

@btsdev btsdev commented Feb 16, 2024

Fix for the hidden and displayed datepicker fields not holding the current values for _job_expires in datepicker.js.

Fixes #2739

Changes Proposed in this Pull Request

  • Properly updates the inputs selected with these selectors: "[name='_job_expires']" and "input[name='_job_expires-datepicker']" with the correct values on the edit page.

Testing Instructions

  • Go to a job edit page and confirm that the value in the field is not blank and is set to the correct value.
  • Look in the dev console to make sure that the hidden field also has the correct value (rather than its value being empty).

Release Notes

  • Fix for the hidden and displayed datepicker fields not holding the current values for _job_expires in datepicker.js.

…rrent values for _job_expires in datepicker.js.
@btsdev btsdev force-pushed the btsdev-Job-Listing-Expiry-Date-Fix-Issue-2739 branch from 1f469e5 to 57e1e2d Compare February 18, 2024 23:32
…n the if branch in the added function 'dateFormatFunction'.
@btsdev btsdev force-pushed the btsdev-Job-Listing-Expiry-Date-Fix-Issue-2739 branch from 656f093 to 5957663 Compare February 18, 2024 23:38
…stency. Moved the code for applying the value fixes to the hidden and target fields at the end of the 'initializeDatepicker' function's code block.
@btsdev btsdev force-pushed the btsdev-Job-Listing-Expiry-Date-Fix-Issue-2739 branch from d5acc05 to ebe347c Compare February 19, 2024 00:53
@btsdev
Copy link
Author

btsdev commented Feb 19, 2024

Not sure how important it was to ensure that the names I added were camelCase (as I see a bit of mixing of naming styles: snake_case and "$snake_case" in some places. However, I won't touch any of that code as that would be out of scope for the purpose of this PR).

The need to add the dateFormatFunction function itself does feel a bit odd as it feels a bit redundant with jquery-ui-datepicker's functionality, but getting the day of the month correct meant I needed to ensure that it was incremented by 1 and also ensure it was always two digits (e.g. "2" should be "02") for some reason (e.g. "2024-02-4" gets converted to "February 4, 2024", but "2024-02-04" gets converted to "February 3, 2024", going back a day for some reason).

The fix to the field values now occurs at the end of the initializeDatepicker function (I initially was applying this at the end of the ready function block, but that seemed inaccurate).

Note that at the end of initializeDatepicker I'm using $target[0].getAttribute("value") rather than $target.val(). I ran into issues where the former code gave me the value, but the latter gave me nothing. I've no idea why this bug was happening, but at least this work around does the job.

I've tested my changes on my client's WP install to ensure this fix is still working.

(also note the force pushes were just to amend some typos in my commit messages)

@mikeyarce mikeyarce self-assigned this Feb 23, 2024
@mikeyarce
Copy link
Member

Hi @btsdev - I had a look at this issue as well and am proposing a more simple solution which you can see here: #2779

Let me know what you think and if you're able to test it at all.

@yscik yscik added this to the 2.2.3 milestone Feb 27, 2024
@mikeyarce
Copy link
Member

Closing this as this other PR fixes it #2779

@mikeyarce mikeyarce closed this Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Job Listing Expiry Date not working in editor
3 participants