Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
self.log.clear()
self.log.extend(self.streams_btn_list)
self.set_focus("body")
self.log.set_focus(self.focus_index_before_search)
if self.log: # Only set focus if list is not empty
self.log.set_focus(self.focus_index_before_search)
self.view.controller.update_screen()
return key
return super().keypress(size, key)
Expand Down Expand Up @@ -478,7 +479,8 @@ def update_topics_list(
if topic_button.topic_name == topic_name:
self.log.insert(0, self.log.pop(topic_iterator))
self.list_box.set_focus_valign("bottom")
if sender_id == self.view.model.user_id:
# Only set focus if list is not empty
if sender_id == self.view.model.user_id and self.log:
self.list_box.set_focus(0)
return
# No previous topics with same topic names are found
Expand All @@ -492,7 +494,8 @@ def update_topics_list(
)
self.log.insert(0, new_topic_button)
self.list_box.set_focus_valign("bottom")
if sender_id == self.view.model.user_id:
# Only set focus if list is not empty
if sender_id == self.view.model.user_id and self.log:
self.list_box.set_focus(0)

def mouse_event(
Expand Down Expand Up @@ -522,7 +525,8 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
self.log.clear()
self.log.extend(self.topics_btn_list)
self.set_focus("body")
self.log.set_focus(self.focus_index_before_search)
if self.log: # Only set focus if list is not empty
self.log.set_focus(self.focus_index_before_search)
self.view.controller.update_screen()
return key
return super().keypress(size, key)
Expand Down
Loading