Skip to content

Commit

Permalink
views/boxes: Reset search only after verifying search status.
Browse files Browse the repository at this point in the history
Added conditional checks to ensure that a search was previously
performed before resetting search, using the newly added search_status.
  • Loading branch information
Niloth-p committed Jun 6, 2024
1 parent ef4662e commit 4258831
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
self.reset_search_text()
self.panel_view.set_focus("body")
# Don't call 'Esc' when inside a popup search-box.
if not self.panel_view.view.controller.is_any_popup_open():
if (
not self.panel_view.view.controller.is_any_popup_open()
and self.panel_view.search_status != SearchStatus.DEFAULT
):
self.panel_view.keypress(size, primary_key_for_command("GO_BACK"))
elif (
is_command_key("ENTER", key)
Expand Down
15 changes: 12 additions & 3 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
self.stream_search_box.set_caption(" ")
self.view.controller.enter_editor_mode_with(self.stream_search_box)
return key
elif is_command_key("GO_BACK", key):
elif (
is_command_key("GO_BACK", key)
and self.search_status != SearchStatus.DEFAULT
):
self.stream_search_box.reset_search_text()
self.log.clear()
self.log.extend(self.streams_btn_list)
Expand Down Expand Up @@ -528,7 +531,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
self.topic_search_box.set_caption(" ")
self.view.controller.enter_editor_mode_with(self.topic_search_box)
return key
elif is_command_key("GO_BACK", key):
elif (
is_command_key("GO_BACK", key)
and self.search_status != SearchStatus.DEFAULT
):
self.topic_search_box.reset_search_text()
self.log.clear()
self.log.extend(self.topics_btn_list)
Expand Down Expand Up @@ -772,7 +778,10 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
self.user_search.set_caption(" ")
self.view.controller.enter_editor_mode_with(self.user_search)
return key
elif is_command_key("GO_BACK", key):
elif (
is_command_key("GO_BACK", key)
and self.search_status != SearchStatus.DEFAULT
):
self.user_search.reset_search_text()
self.allow_update_user_list = True
self.body = UsersView(self.view.controller, self.users_btn_list)
Expand Down

0 comments on commit 4258831

Please sign in to comment.