Skip to content

Commit addb62c

Browse files
committed
boxes/views: Keep the log focus constant while the search is active.
This amends update_streams and update_topics to set the log focus to the start while the search is active. NOTE: Sets a regression in the focus_index_before_search logic where now the list shifts itself after 'esc' is pressed.
1 parent ecd883b commit addb62c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

zulipterminal/ui_tools/boxes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,13 @@ def reset_search_text(self) -> None:
12121212
self.set_caption('')
12131213
self.set_edit_text(self.search_text)
12141214

1215+
def reset_active_search_focus(self) -> None:
1216+
"""
1217+
Sets focus to the start on every callback to update_function.
1218+
"""
1219+
if len(self.panel_view.log):
1220+
self.panel_view.body.set_focus(0)
1221+
12151222
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
12161223
if ((is_command_key('ENTER', key)
12171224
and self.get_edit_text().lstrip() == '')

zulipterminal/ui_tools/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ def update_streams(self, search_box: Any, new_text: str) -> None:
317317

318318
self.log.clear()
319319
self.log.extend(streams_display)
320+
self.stream_search_box.reset_active_search_focus()
320321
self.view.controller.update_screen()
321322

322323
def mouse_event(self, size: urwid_Size, event: str, button: int, col: int,
@@ -386,6 +387,7 @@ def update_topics(self, search_box: Any, new_text: str) -> None:
386387
]
387388
self.log.clear()
388389
self.log.extend(topics_to_display)
390+
self.topic_search_box.reset_active_search_focus()
389391
self.view.controller.update_screen()
390392

391393
def update_topics_list(self, stream_id: int, topic_name: str,

0 commit comments

Comments
 (0)