-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
sortableFields have default sorting option #4774
Conversation
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.
Hi @KancerEzeroglu and thank you for this.
A few comments:
-
We would like to keep the config backwards compatible. With this PR anyone with existing
sortable_fields
will have to update their config. We can add migration code here:
https://github.com/netlify/netlify-cms/blob/567438fdd1aa775fd09a6a5de13e79c9d783e0d6/packages/netlify-cms-core/src/actions/config.js#L283 -
The current suggested API allows setting multiple fields as the default which is not supported by the UI. We can use something like:
sortable_fields: { names: ['title','date'], default: name, direction: descending }
- I think it would be better to initialize the default sort in the reducer to avoid the UI refreshing after initial load.
WDYT?
Sorry for the late reply @erezrokah |
In the future, we can enable users to do multiple sorts. |
Hi @KancerEzeroglu and sorry again for the late reply. How about enforcing using our schema validation that only a single field has a |
Closing this as stale. Let me know if you'd like me to re-open it |
It would be really nice to have default sort ordering for date fields. With a lot of posts, having the default be date ascending is not a great user experience... Is the |
Hi @jlev the blockers for the PR are:
Please note that the CMS remembers the user's preference for the sort if that helps and having a default sort field can impact performance quite a lot as it requires the CMS to fetch all posts on initial load. |
closes #3715
Summary
We couldn't set the default sortable field from the config file.
With my changes, it can happen.
You can specify the sortable fields like below:
Test plan
I haven't added the tests in the code (I've removed those that belong to the sortable fields test).
I would like to be sure my direction is right.
A picture of a cute animal (not mandatory but encouraged)