Skip to content

Exclude unsortable primary key from the sort menu - #2858

Open
Sanjays2402 wants to merge 1 commit into
simonw:mainfrom
Sanjays2402:fix/sort-menu-unsortable-pk-1980
Open

Exclude unsortable primary key from the sort menu#2858
Sanjays2402 wants to merge 1 commit into
simonw:mainfrom
Sanjays2402:fix/sort-menu-unsortable-pk-1980

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #1980

When a table sets sortable_columns without the primary key, the sort dropdown still listed it, so picking it returned "Cannot sort table by id". display_columns_and_rows() rebuilds the pk as the leading link column and hardcoded "sortable": len(pks) == 1 instead of checking sortable_columns; it now checks it like every other column.

New test in tests/test_table_html.py fails without the change and passes with it.

When a table configures sortable_columns and omits the primary key, the
sort dropdown still offered it. display_columns_and_rows() rebuilds the
primary key as the leading link column and hardcoded its "sortable" flag
to len(pks) == 1 instead of consulting sortable_columns, so selecting it
produced a 500/400 "Cannot sort table by id" error.

The flag now checks sortable_columns like every other column.

Adds tests/test_table_html.py::test_sort_menu_excludes_unsortable_primary_key.
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.

"Cannot sort table by id" when sortable_columns is used

1 participant