Skip to content

fix: Also apply sort params to existing fields in a ListGuesser #629

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zolex
Copy link
Contributor

@zolex zolex commented Jun 8, 2025

Q A
Branch? main
Tickets partially fixes #626
License MIT
Doc PR -

Also apply sort params to existing fields in a ListGuesser instead of only "empty" listguessers.

Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for offering to contribute in any case!

Comment on lines +178 to +183
const fieldProps = {
...field.props,
key: field.props.source + (orderField ? `-${orderField}` : ''),
sortBy: orderField,
sortable: !!orderField,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this is overriding existing props on the field, e.g. if you had set sortable={false} then this is lost.

Besides, IMO this is not the react-admin way to do things.
As of late react-admin tends to avoid inspecting the children and overriding their props directly as this can lead to unexpected behaviors. Instead, I wonder if the best solution would rather be to update the getOverrideCode to include the sortBy and sortable props in the generated code, which would encourage users to keep those props once they move to providing their own children.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this is overriding existing props on the field, e.g. if you had set sortable={false} then this is lost.

Besides, IMO this is not the react-admin way to do things. As of late react-admin tends to avoid inspecting the children and overriding their props directly as this can lead to unexpected behaviors. Instead, I wonder if the best solution would rather be to update the getOverrideCode to include the sortBy and sortable props in the generated code, which would encourage users to keep those props once they move to providing their own children.

thanks for the input, I will have a look.

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.

Various API Filters not showing in the UI
2 participants