-
-
Notifications
You must be signed in to change notification settings - Fork 278
Panel Search Box UI Enhancements #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The last commit fixes a bug caused by mouse clicking on search, but I'm not entirely sure about the solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rohitth007 Thanks for your work. This seems to work well functionally. 👍
That said, I would like to mention a couple of points related to the commits:
- Given that we label all other types of changes in the version control, feature changes do not need labels like enhancement, feature, etc (it is implicit). You could take a look at the recently merged commit guidelines in the README.
- We could improve the commit titles and description. Ideally, we should be able to identify what the commit is doing just by reading the commit title. Generic titles (e.g.: "Improve UI") don't give enough context. Commit descriptions should aim to give an overview than explain what the code is doing literally.
Other than that, the PR looks good overall. I have left a few minor in-line comments. :)
zulipterminal/ui_tools/boxes.py
Outdated
@@ -1726,7 +1726,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
self.panel_view.keypress(size, "esc") | |||
elif is_command_key("ENTER", key) and not self.panel_view.empty_search: | |||
self.panel_view.view.controller.exit_editor_mode() | |||
self.set_caption([("filter_results", "Search Results"), " "]) | |||
self.set_caption([("filter_results", " Search Results"), " "]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding " " as another item would look better as this currently applies the styling to Search results
as well. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely agree with this. Generally the extra space looks good though 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -367,7 +367,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
if is_command_key("SEARCH_STREAMS", key): | |||
_, self.focus_index_before_search = self.log.get_focus() | |||
self.set_focus("header") | |||
self.stream_search_box.set_caption("") | |||
self.stream_search_box.set_caption(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding an extra " " in a method that overrides urwid's set_caption
method in PanelSearchBox
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was instead thinking, during the Panel refactor I could group this and 1 other common line into a function call enter_search_mode
inside PanelSearchBox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good function to add during the first commit - it avoids spreading general set_caption
calls through the code, which may also be used for other things, as well as providing a central place for this kind of change - and it's easy to grep for a unique name :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@preetmishra @neiljp Previously, the other common line that I was talking about was enter_editor_mode
but now that I see that enter_editor_mode would be removed after the keypress refactor and set_caption would be called only once anyway after the Panel refactor, I don't think this needs to be moved into PanelSearchBox using enter_search_mode or similar.
zulipterminal/ui_tools/boxes.py
Outdated
@@ -1726,7 +1726,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
self.panel_view.keypress(size, "esc") | |||
elif is_command_key("ENTER", key) and not self.panel_view.empty_search: | |||
self.panel_view.view.controller.exit_editor_mode() | |||
self.set_caption([("filter_results", " Search Results"), " "]) | |||
self.set_caption([("filter_results", " Search Results\n"), " > "]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait for everybody's views on this in the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - also if this is separate to other changes that are less controversial then having it last make it easier to merge the others first.
zulipterminal/ui_tools/views.py
Outdated
@@ -368,6 +368,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
_, self.focus_index_before_search = self.log.get_focus() | |||
self.set_focus("header") | |||
self.stream_search_box.set_caption(" ") | |||
self.view.controller.enter_editor_mode_with(self.stream_search_box) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand what the code does but I suspect that the commit description isn't accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some changes and can be found at #1072
zulipterminal/ui.py
Outdated
@@ -208,8 +208,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]: | |||
or is_command_key("PRIVATE_MESSAGE", key) | |||
): | |||
self.body.focus_col = 1 | |||
self.middle_column.keypress(size, key) | |||
return key | |||
return self.middle_column.keypress(size, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of minor changes, we could point out what the code does exactly in the commit title. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some changes and can be found at #1072
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rohitth007 You have a range of changes here - design changes (one needing discussion), general refactoring (towards panel simplification/combination), and a mouse bugfix. I'm not sure if they're all connected or dependent - though you may be changing the same files of course - but having them in the same PR isn't going to help this get merged very fast as each aspect has a range of different discussions required, and it makes reviewing more complex and time-consuming.
My impression is that the first 2-3 could be merged fairly quickly with a few changes and some simplification to the commit text - we could discuss writing styles in the ZT stream or the ZT GSoC one, or maybe PMs (but fewer people can contribute that way).
The refactoring is good to see too, but unless the changes are tightly coupled with the others it may be easier to have a separate PR for it, and for the mouse bugfix separately.
zulipterminal/ui_tools/boxes.py
Outdated
@@ -1726,7 +1726,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
self.panel_view.keypress(size, "esc") | |||
elif is_command_key("ENTER", key) and not self.panel_view.empty_search: | |||
self.panel_view.view.controller.exit_editor_mode() | |||
self.set_caption([("filter_results", "Search Results"), " "]) | |||
self.set_caption([("filter_results", " Search Results"), " "]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely agree with this. Generally the extra space looks good though 👍
@@ -367,7 +367,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
if is_command_key("SEARCH_STREAMS", key): | |||
_, self.focus_index_before_search = self.log.get_focus() | |||
self.set_focus("header") | |||
self.stream_search_box.set_caption("") | |||
self.stream_search_box.set_caption(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good function to add during the first commit - it avoids spreading general set_caption
calls through the code, which may also be used for other things, as well as providing a central place for this kind of change - and it's easy to grep for a unique name :)
zulipterminal/ui_tools/boxes.py
Outdated
@@ -1726,7 +1726,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
self.panel_view.keypress(size, "esc") | |||
elif is_command_key("ENTER", key) and not self.panel_view.empty_search: | |||
self.panel_view.view.controller.exit_editor_mode() | |||
self.set_caption([("filter_results", " Search Results"), " "]) | |||
self.set_caption([("filter_results", " Search Results\n"), " > "]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - also if this is separate to other changes that are less controversial then having it last make it easier to merge the others first.
9e26a49
to
26ba08b
Compare
@preetmishra @neiljp I have split the PR as discussed and also dropped the mouse-fix commit as I think it would automatically get resolved with the keypress refactor. This PR only contains the Panel Search UI improvement features. (3 commits) |
This commit erases `caption` and keeps `edit_text` while reattempting a search. `edit_text` was being erased every time because `search_text` had to be erased, hence keeping the `edit_text` becomes a problem. To solve this, the default `search_text` was used in caption instead and `edit_text` was set to ''. Removing the line that empties text in ui.py gives the feature we want. `set_content('')` is used so that now, when a user presses `q` for a second search the caption becomes empty. This makes for a cleaner UI while searching by removing caption `Search Results` when typing. Tests updated.
This commit aligns the text in PanelSearchBox to keep consistency with rest of the text in the panel. Tests updated.
This commits displays `edit_text` on a newline to differentiate clearly what is searched for, add aesthetic appeal by using `\n > ` and better render long `edit_text`s. Tests updated.
26ba08b
to
85193aa
Compare
The rest of the commits can be found at #1072. |
Heads up @Rohitth007, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
@Rohitth007 I just merged the first two of these separately since they are a definite improvement 🎉 However, there's been little feedback or testing of the other change, which could possibly be more convincing accompanied by other changes - such as adding hotkey hints, using a horizontal bar of color to indicate results, and whether we want a search 'prompt' (the There is also scope for unifying some parts of the message search UI, at least in terms of how it is presented, after this change. |
I'm marking this as a PR completion candidate, but this will likely need some rounds of iteration to generate a consistent design, or perhaps a proposal and discussion beforehand to eg. consider how hotkeys currently work and how to represent that. The main hotkey hinting issue here is how once we enter a search state then users get no hints (at a minimum of) how to
So, dynamically showing the appropriate keys would be useful for that. For the multi-line layout, my previous concern was re the search UI jumping; I'm not sure there's a way around that. Re a 'prompt' (like the Note that some of the original PR here has been merged already, but was discussed at #zulip-terminal>Panel search box UI. |
This PR deals UI enhancements related to display and reattempting search.
While reattempting search:
Display: