Skip to content

Join table state does not reflect default sort #12083

Closed
@coreyleelarson

Description

@coreyleelarson

Describe the Bug

I've noticed the join table state does not reflect a default sort. The data is sorted correctly, but the sort columns do not show any active sorting.

For me, this is mainly a problem when setting orderable: true for the join field. I cannot re-order the rows until I click to toggle the draggable sort header. However, even explicitly setting defaultSort on the join field doesn't work, either.

Image

This works fine for a regular collection. I think the issue stems from the <ListQueryProvider /> only setting the default state when the modifySearchParams prop is true:

const [currentQuery, setCurrentQuery] = useState<ListQuery>(() => {
  if (modifySearchParams) {
    return searchParams
  } else {
    return {}
  }
})

Link to the code that reproduces this issue

https://github.com/coreyleelarson/payload

Reproduction Steps

  • Run pnpm dev sort
  • Navigate to the "Orderable Joins" collection
  • Navigate to the "Join A" resource
  • Observe there is no default sort on the join tables
  • Try to reorder one of the join tables
  • Observe the error message

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Binaries:
  Node: 22.14.0
  npm: 11.2.0
  Yarn: N/A
  pnpm: 10.7.1
Relevant Packages:
  payload: 3.33.0
  next: 15.3.0
  @payloadcms/db-mongodb: 3.33.0
  @payloadcms/email-nodemailer: 3.33.0
  @payloadcms/graphql: 3.33.0
  @payloadcms/next/utilities: 3.33.0
  @payloadcms/payload-cloud: 3.33.0
  @payloadcms/richtext-lexical: 3.33.0
  @payloadcms/translations: 3.33.0
  @payloadcms/ui/shared: 3.33.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:06 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8103
  Available memory (MB): 8192
  Available CPU cores: 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions