Skip to content
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

Clearing sorting on table columns do not actually clear. #2756

Closed
mrdobalina2k opened this issue Oct 31, 2024 · 1 comment · Fixed by #2759
Closed

Clearing sorting on table columns do not actually clear. #2756

mrdobalina2k opened this issue Oct 31, 2024 · 1 comment · Fixed by #2759
Labels
bug Something isn't working

Comments

@mrdobalina2k
Copy link

Describe the bug

I have a table that I want to select some values from. I often use sorting, because it makes it easier to select a row that has a particular value, like a score or some other value.

I've noticed that if I clear the sorting, the tables revert to normal, but if select a row again, the selected row (the .value property of the table) remains as if it's still sorted.

Environment

{
"marimo": "0.9.14",
"OS": "Windows",
"OS Version": "11",
"Processor": "Intel64 Family 6 Model 126 Stepping 5, GenuineIntel",
"Python Version": "3.12.2",
"Binaries": {
"Browser": "129.0.6668.60",
"Node": "v20.14.0"
},
"Dependencies": {
"click": "8.1.7",
"docutils": "0.20.1",
"itsdangerous": "2.2.0",
"jedi": "0.19.1",
"markdown": "3.6",
"narwhals": "1.9.3",
"packaging": "24.0",
"psutil": "5.9.8",
"pygments": "2.17.2",
"pymdown-extensions": "10.7.1",
"pyyaml": "6.0.1",
"ruff": "0.5.2",
"starlette": "0.37.2",
"tomlkit": "0.12.4",
"typing-extensions": "4.12.2",
"uvicorn": "0.29.0",
"websockets": "11.0.3"
},
"Optional Dependencies": {
"pandas": "2.2.2"
}
}

Code to reproduce

A very simple example is this one.
Sort the "data" column by value. For the example use descending. Then select the first row that has the highest value, and observe the table.value is correct. Clear the sorting, and reselect the first row, which now shows 1 in the UI, but observe how the .value is actually 4!

import marimo

__generated_with = "0.9.14"
app = marimo.App(width="medium")


@app.cell
def __():
    import marimo as mo
    return (mo,)


@app.cell
def __(mo):
    table=mo.ui.table([{"data": 1}, {"data": 2}, {"data": 3}, {"data": 4}])
    table
    return (table,)


@app.cell
def __(table):
    table.value
    return


if __name__ == "__main__":
    app.run()
@mrdobalina2k mrdobalina2k added the bug Something isn't working label Oct 31, 2024
@mscolnick
Copy link
Contributor

Thanks for the detailed repro. I was able to fix this (#2759) and will be out in the next release.

mscolnick added a commit that referenced this issue Oct 31, 2024
Fixes #2756

There is a subtle bug when clearing table sort/filter, we reverted back
to the initial page but we did not tell the backend, so the was an
inconsistency in state. This fixes it while still showing the initial
state when possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants