-
Notifications
You must be signed in to change notification settings - Fork 638
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
[4.x]: orderBy: 'postDate desc' leads to unexpected results in live preview #11272
Comments
Hmm, good point! Decided the best way to fix this is to start setting placeholder Post Dates on newly-created entries, which get replaced once the author sets their own Post Date value or when the entry gets fully saved. The fix was a bit involved though, so made the change for Craft 4.1 instead of the next 4.0.x release. |
@brandonkelly Thanks, just took a look at 4.1.x-dev and noticed a placeholder post date is now set but not shown in the UI. However, that looks like why the first automatic save resets the post date to NULL. Wouldn't mind to see the post date in the form though, somehow marked as 'provisional'. It can appear on the live preview pages, and people might wonder where it came from if it's blank in the form. |
Fixes bug where the first time an unpublished draft was saved, the placeholder post date would get emptied out (#11272 (comment)).
Ah of course. Just fixed that for the next release. Thanks for testing! |
Craft 4.1 is out with this change ✨ |
What happened?
Description
Maybe technically not a bug, but an unexpected behavior that is somewhat hard to catch/fix:
A new entry is now created with an empty Post Date, so when
postDate desc
is used asorderBy
in Live Preview (either by default or explicitly set), the new entry is pushed to the end of the list instead to the top as in 3.x.(Could not find that in the upgrade docs btw.)
Can be fixed by something like
orderBy: expression('postDate is null desc, postDate desc')
, but I think that breaks the simplicity Craft wants to provide, and should be handled in core.Steps to reproduce
postDate is not set by hand
orderBy
criteria or setorderBy: 'postDate desc
in preview targetsExpected behavior
The new entry is handled as 'newest' both in preview and after being published
Actual behavior
It is handled as 'oldest' in preview, and 'newest' when published
/Mel & Aylin
Craft CMS version
4.0.2
PHP version
8.1.5
Operating system and version
Windows 10
Database type and version
MySQL 5.7.14
Image driver and version
Imagick 3.7.0 (ImageMagick 7.1.0-18)
Installed plugins and versions
None
The text was updated successfully, but these errors were encountered: