-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
[wip] Search pills #9716
[wip] Search pills #9716
Conversation
@showell can you take this review? |
There's a typo in one of the commit messages--search_pil.js. |
static/js/search.js
Outdated
updater: function (search_string) { | ||
// Order is important here. narrow_or_search_for_term | ||
// assumes that the pill for the selected typeahead has | ||
// not been added. |
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.
Can you explain why that's the case? If I'm just reading this comment, I don't really know why narrow_or_search_for_term
has that restriction, and maybe we can figure out a way so they don't depend on each other? (I think the main thing is just to add to the comment.)
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.
narrow_or_search_for_term gets a search string from existing pills and obtains existing operators. Newly selected suggestion is added to those operators. If narrow_or_search_for_term was called after append_search_string, the existing search pills at the time for calling that function would also have the newly selected suggestion, and appending it again would cause duplication.
I've also added above text to the comment.
I did a first pass on this, and the overall code seems really clean. I made a couple small comments, and the build seems to have failed. |
@shubham-padia What is the status of your TODO list in the top comment here? Is there anything we should hold off on merging? |
@showell I was out for today, I'll get to the todo list tommorow. The first four commits should be good to merge. The commits after that start making changes to the UI, it would be best to merge them once the UI bugs are fixed. |
34be3b7
to
01f72a6
Compare
@showell I've pushed the following changes: The failure mentioned in point no.2 exists from dedb182 to b92bc4a. It is fixed in f84b78a. It was not fixable in a single commit and I did not change the history in that case. |
@showell I'm curious about the merging policy here. I'm presuming that we will be merging this once the UI bugs are fixes and the UI seems stable. Is that correct? |
@shubham-padia That's correct. If you can set up your branch so that the first N commits are no-brainer merges (i.e. simple refactorings that pass all tests), I would consider opening a separate PR for them called something like "Add prep commits for search pills" and clearly link back to this PR (which already has "wip" in the title--thanks for doing that). |
Cool :) Although the first 4 commits are mergeable, I'll let them be as it is a file addition and I see no advantage in merging it beforehand. |
2b2b91b
to
3897bd9
Compare
Update: UI changes have been made and are under review on https://chat.zulip.org/#narrow/stream/101-design/topic/search.20pills .
|
Changes since the last update:
@showell @timabbott I've made the changes from the feedback on czo and some other irregularities I encountered. It'd be great to have a review on this. I feel this is a fairly stable experience for now and any other UI/behavourial enhancements should be opened as a follow up. |
Whenever the cross icon was not visible i.e empty search bar out |
8e4c4b2
to
c4fa744
Compare
pinging @showell for review. (I think the previous request for review may have been buried in the multiple emails, please ignore otherwise 😃 ) |
357615b
to
a83cca1
Compare
I guess completion now works one pill at a time? It's actually kind of nice for some situations. This seems to prevent negated search, or at least make it hard to edit. |
If I type "is:private", that turns into a pill, and so far, so good. Then I type "V" and I'm presented with "stream Verona" as an option, which seems wrong, since "is:private" and "stream:Verona" are mutually exclusive options. I was able to confirm this bug was introduced by your PR, and I believe it has to do with not properly setting
|
Yes, the suggestions do not take previous pills into account right now. I was hoping to do that once the current code gets reviewed. I'll investigate the other UI bugs. |
This setting isn't intended to exist long term, but instead to make it possible to merge our search pills code before we're ready to cut over production environments to use it.
This is preparation for being able to work on the search pills feature without making any user-facing changes until we're ready to enable it.
This way, we can edit the CSS for the searchbox without having to worry about changing the legacy behavior.
Input pills require a contenteditable div with a class named input to fall inside the pill container. On converting the input tag into a div, the size of the input decreases which is compensated by a line-height of 40px. Comment above letter-spacing:normal was removed as chrome and firefox do not change the letter-spacing to normal for a div via the default browser stylesheet. NOTE: Currently writing something into the div will call the action corresponding to that key in the keyboard shortcuts. The input will work fine once the pills have been initiated. For the casper tests, for now, we just use the legacy search code. When we change that, $.val() cannot be used on contenteditable div, so $.html() will need to be used instead in select_item_via_typeahead.
Adds the initialize function to search_pill_widget.js for initializing a pill object on search query box.
The letter-spacing was changed last in commit fc4d80d which is about a 5 year old commit at the point of writing. The change is removed as I did not notice any visual change on removing it. Changing the letter spacing to normal lets the text in the pills be seen legibly, otherwise the characters were overlapping.
This forks off search_legacy.js and search_suggestion_legacy.js so that we can continue running automated tests against the legacy search code while we develop the input pills feature.
Adds an optional parameter `quiet` to removeLastPill and removeAllPills. If `quiet` is a truthy value, the event handler associated with the pill will not be evaluated. This is useful when using clear to reset the pills.
4bcc3d2
to
3095435
Compare
Following points have been implemented in this commit: 1.) Add search pill on selecting typeahead. 2.) Re-narrow after removing a search pill. 3.) Add quiet optional parameter to removeLastPill. 4.) Pre populate search pills in narrow.activate. 5.) Clear existing search pills on narrow.deactivate. Description of above points: 1.) I tried out using the description from suggestions.lookup_table to append a pill using appendValidatedData so that the description had not to be calculated again. But the description in the suggestions lookup contains html due to highlighting. This html is escaped when inputed in a pill. An attempt was also made to remove the higlighting by replacing the tags. But other espaced characters like < also popped up, so it was better to use append_search_string. 3.) If one wants to refresh the pill using pill.clear and wants to repopulate them, evaluating the event_handler associated with the action of removing the pill may not be desired. 4.) Pill population code is added to narrow.activate. Pills are not populated if the narrow was triggered by search as search handles the addition and removal of pill by itself. The reason for not handling search too in narrow.activate is to avoid clearing the pills and repopulating them. Example of some of the triggers for narrow.activate include `restore draft`, `topic change`,`sidebar`. Also modifies tests for search.js
tab_bar.js becomes redundant after implementation of search pills. This commit adds a comment to tab_bar.initiliaze, so the event listeners related to it do not get initiated. This does not remove any code related to tab_bar.js. Also adds left and right border around the search icon.
This large function will need to be modified significantly as part of the pills effort, and copying it lets us preserve behavior in production until we're ready to cut things over.
This lets us modify the implementation of this function for the search pills implementation only.
After adding search pills, suggestions were based only on the current input and no validation against the existing pills was done. operator_subset_suggestions have been removed. Default suggestions for base_operators have also been removed. Handle multiple operators: if `is:starred stream:Ver` was typed without selecting the typeahead or pressing enter in between i.e search pill for is:starred has not yet been added, then the description of `is:starred` will act as a prefix in every suggestion. Also makes changes re-enabling person suggestions for names with spaces.
Previously `All messages` was displayed irrespective of the existing pills. Now the suggestion is displayed only if no pills are present
8568d9b
to
af64797
Compare
Adds box-shadow to `#searchbox` when either `#search_query` or any of the pills have focus. Uses jquery instead of pure css as the `:focus` event occurs on `#search_query`, while we want to add box-shadow to `#searchbox`. This could have been done with `:focus-within` CSS selector, but it is not supported in IE or Opera. `#search_query` already had an onfocus/focusout listener, adding listeners to `#searchbox.pills` for those events wouldn't have worked as you don't want the focusout event to fire when the focus shifts from input to pill. Also adds `focusin`, `focusout` and `css()` to zjquery. `css` is same as `val`, except it returns an empty object in case of no value instead of an empty string. I don't think `css()` is valid syntax in actual jquery.
`compose_pm_pill.my_pill`, `search_pill_widget.my_pill` and any of its occurrences throughout the app have been replaced to use `widget` instead.
8ecfac9
to
29d361c
Compare
…abled. If search pills are not enabled, the text present in the search bar will be selected on pressing '/' and writing someting without deselecting the text will clear the search text. Since selecting the pills would not make sense in this context, the search box is focused instead.
Pressing `Esc` did not blur a contenteditable div by default, while an input field was blurred by default. Due to this when a user tried to unnarrow using `Esc` key when the searchbox had focus, the focus remained stuck in the div itself and no further action was taken.
29d361c
to
13abbc6
Compare
Update:
|
I made one change to ef2f6b7, which is to add a I also updated the checklist of follow-up items, above, based on your comment. Can you move the remaining to a new issue, that we use as the "remaining search pills implementation details" TODO list? This PR has a long enough history that it's not a great place to keep that. One other detail worth mentioning: Changes @synicalsyntax made to the user pills ended up breaking some of the styling for this; so you two will want to collaborate to get the search pills styling correct again. I'm looking forward to this! Aside from the few annoying quirks, this feels a lot nicer :) |
Opened #10026 for follow-up issues |
Immediate TODO: