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

Add scroll_index to Column #7206

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add scroll_index to Column #7206

wants to merge 4 commits into from

Conversation

ahuang11
Copy link
Contributor

@ahuang11 ahuang11 commented Aug 29, 2024

Closes #6083

import panel as pn

pn.extension()

def scroll_to_top(event):
    column.scroll_index = 100


column = pn.Column(
    *list(range(1000)),
    height=300,
    sizing_mode="fixed",
    scroll=True,
)
btn = pn.widgets.Button(name="Scroll to top", width=200, button_type="primary", on_click=scroll_to_top)
pn.Row(column, btn).servable()

(poorly named btn; should be scroll to index 100)

Screen.Recording.2024-08-29.at.12.46.16.PM.mov

@ahuang11 ahuang11 changed the title Add scroll index Add scroll_index to Column Aug 29, 2024
Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 82.24%. Comparing base (647db1a) to head (b712cfc).

Files with missing lines Patch % Lines
panel/tests/ui/layout/test_column.py 30.76% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7206   +/-   ##
=======================================
  Coverage   82.24%   82.24%           
=======================================
  Files         331      331           
  Lines       49420    49438   +18     
=======================================
+ Hits        40647    40662   +15     
- Misses       8773     8776    +3     

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

@philippjfr philippjfr added this to the v1.6.0 milestone Sep 9, 2024
@@ -939,6 +939,12 @@ class Column(ListPanel):
will update the scroll position of the Column. Setting to
0 will scroll to the top.""")

scroll_index = param.Integer(default=None, bounds=(0, None), doc="""
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be implemented as a scroll_to_index method which sends an event to the frontend (e.g. like the HTML diff approach).

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.

Make Column scroll position usefull
2 participants