Skip to content
Closed
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,16 @@ def reset_search_text(self) -> None:
self.set_caption('')
self.set_edit_text(self.search_text)

def reset_active_search_focus(self) -> None:
"""
Sets focus to the start on every callback to update_function.
"""
if len(self.panel_view.log):
self.panel_view.body.set_focus(0)

def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
if ((is_command_key('ENTER', key) and self.get_edit_text() == '')
if ((is_command_key('ENTER', key)
and self.get_edit_text().lstrip() == '')
or is_command_key('GO_BACK', key)):
self.panel_view.view.controller.exit_editor_mode()
self.reset_search_text()
Expand Down
9 changes: 9 additions & 0 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ def __init__(self, streams_btn_list: List[Any], view: Any) -> None:

@asynch
def update_streams(self, search_box: Any, new_text: str) -> None:
new_text = new_text.lstrip()

if not self.view.controller.is_in_editor_mode():
return
# wait for any previously started search to finish to avoid
Expand Down Expand Up @@ -315,6 +317,7 @@ def update_streams(self, search_box: Any, new_text: str) -> None:

self.log.clear()
self.log.extend(streams_display)
self.stream_search_box.reset_active_search_focus()
self.view.controller.update_screen()

def mouse_event(self, size: urwid_Size, event: str, button: int, col: int,
Expand Down Expand Up @@ -369,6 +372,8 @@ def __init__(self, topics_btn_list: List[Any], view: Any,

@asynch
def update_topics(self, search_box: Any, new_text: str) -> None:
new_text = new_text.lstrip()

if not self.view.controller.is_in_editor_mode():
return
# wait for any previously started search to finish to avoid
Expand All @@ -382,6 +387,7 @@ def update_topics(self, search_box: Any, new_text: str) -> None:
]
self.log.clear()
self.log.extend(topics_to_display)
self.topic_search_box.reset_active_search_focus()
self.view.controller.update_screen()

def update_topics_list(self, stream_id: int, topic_name: str,
Expand Down Expand Up @@ -626,6 +632,9 @@ def update_user_list(self, search_box: Any=None,
if not self.allow_update_user_list and new_text is None:
return

if new_text is not None:
new_text = new_text.lstrip()

# wait for any previously started search to finish to avoid
# displaying wrong user list.
with self.search_lock:
Expand Down