Skip to content

Commit

Permalink
Fix visible range on objects set in Feed (#7673)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Feb 13, 2025
1 parent afe6e2a commit b245bbb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 11 additions & 1 deletion panel/layout/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import param

from ..models.feed import Feed as PnFeed, ScrollButtonClick, ScrollLatestEvent
from ..util import edit_readonly
from ..util import edit_readonly, isIn
from .base import Column

if TYPE_CHECKING:
Expand Down Expand Up @@ -154,6 +154,16 @@ def _get_objects(
self, model: Model, old_objects: list[Viewable], doc: Document,
root: Model, comm: Comm | None = None
):
# If no previously visible objects are visible now, reset the visible range
events = self._in_process__events.get(doc, {})
if (
self._last_synced and
'visible_range' not in events and
not any(isIn(old_objects[i], self.objects) for i in range(*self._last_synced))
):
with edit_readonly(self):
self.visible_range = None

from ..pane.base import RerenderError
new_models, old_models = [], []
self._last_synced = self._synced_range
Expand Down
14 changes: 14 additions & 0 deletions panel/tests/ui/layout/test_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,17 @@ def test_feed_dynamic_objects(page):

wait_until(lambda: expect(page.locator('pre').first).to_have_text('0'))
wait_until(lambda: page.locator('pre').count() > 10, page)

def test_feed_reset_visible_range(page):
feed = Feed(*list(range(ITEMS)), load_buffer=20, height=50, view_latest=True)
serve_component(page, feed)

wait_until(lambda: int(page.locator('pre').last.inner_text() or 0) == 99, page)

# set objects to 20
feed.objects = feed.objects[:20]

# assert view reset
wait_until(lambda: (

Check failure on line 174 in panel/tests/ui/layout/test_feed.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:macos-latest

test_feed_reset_visible_range playwright._impl._errors.TimeoutError: Locator.inner_text: Timeout 20000ms exceeded. Call log: waiting for locator("pre").last
int(page.locator('pre').last.inner_text() or 0) == 19
), page)

0 comments on commit b245bbb

Please sign in to comment.