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

fix: Use correct offset in snapshot (#2217) #2318

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

mofojed
Copy link
Member

@mofojed mofojed commented Dec 17, 2024

  • Was using row.offsetInSnapshot, which was a "protected" API and recently removed from the JS API
  • API was removed in JS API refactoring: refactor: Rewrite JS API to share server implementation of Flight/Barrage deephaven-core#5890
  • Instead just use the viewport offset and add the index of the row in the snapshot, which is there in both versions of the API
  • New API does support row.index, but this way is compatible with both
  • Updated unit tests
  • Tested using a deephaven.ui.list_view:
from deephaven import time_table, ui
import datetime

initial_row_count = 200
column_types = time_table(
    "PT1S",
    start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count),
).update(
    [
        "Id=new Integer(i)",
        "Display=new String(`Display `+i)",
    ]
)

@ui.component
def ui_list_view_table():
    value, set_value = ui.use_state([])

    lv = ui.list_view(
        column_types,
        aria_label="List View",
        on_change=set_value,
        selected_keys=value,
    )

    text = ui.text("Selection: " + ", ".join(map(str, value)))

    return ui.flex(
        lv,
        text,
        direction="column",
        margin=10,
        gap=10,
        width=500,
        # necessary to avoid overflowing container height
        min_height=0,
    )

lv_table = ui_list_view_table()

(cherry picked from commit a479d6c)

- Was using `row.offsetInSnapshot`, which was a "protected" API and
recently removed from the JS API
- API was removed in JS API refactoring:
deephaven/deephaven-core#5890
- Instead just use the viewport `offset` and add the index of the row in
the snapshot, which is there in both versions of the API
- New API does support `row.index`, but this way is compatible with both
- Updated unit tests
- Tested using a deephaven.ui.list_view:
```python
from deephaven import time_table, ui
import datetime

initial_row_count = 200
column_types = time_table(
    "PT1S",
    start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count),
).update(
    [
        "Id=new Integer(i)",
        "Display=new String(`Display `+i)",
    ]
)

@ui.component
def ui_list_view_table():
    value, set_value = ui.use_state([])

    lv = ui.list_view(
        column_types,
        aria_label="List View",
        on_change=set_value,
        selected_keys=value,
    )

    text = ui.text("Selection: " + ", ".join(map(str, value)))

    return ui.flex(
        lv,
        text,
        direction="column",
        margin=10,
        gap=10,
        width=500,
        # necessary to avoid overflowing container height
        min_height=0,
    )

lv_table = ui_list_view_table()
```

(cherry picked from commit a479d6c)
@mofojed mofojed requested a review from mattrunyon December 17, 2024 20:04
@mofojed mofojed self-assigned this Dec 17, 2024
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.66%. Comparing base (b0a8658) to head (e3b6184).

Additional details and impacted files
@@                Coverage Diff                @@
##           release/v0.85    #2318      +/-   ##
=================================================
- Coverage          46.66%   46.66%   -0.01%     
=================================================
  Files                685      685              
  Lines              38490    38488       -2     
  Branches            9587     9773     +186     
=================================================
- Hits               17961    17959       -2     
+ Misses             20519    20477      -42     
- Partials              10       52      +42     
Flag Coverage Δ
unit 46.66% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mofojed mofojed merged commit b02116d into deephaven:release/v0.85 Dec 17, 2024
11 checks passed
@mofojed mofojed deleted the v0.85-blank-listview branch December 17, 2024 20:20
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants