-
Notifications
You must be signed in to change notification settings - Fork 11
feat: adding server side search support #723
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
Conversation
Need feedback on the api. Goal: Questions: |
Codecov Report
@@ Coverage Diff @@
## main #723 +/- ##
==========================================
- Coverage 85.15% 85.15% -0.01%
==========================================
Files 784 784
Lines 16064 16070 +6
Branches 1997 1999 +2
==========================================
+ Hits 13680 13685 +5
- Misses 2351 2352 +1
Partials 33 33
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
public enableSearch: boolean = false; | ||
|
||
@Input() | ||
public enableImplicitOptionsSearch: boolean = true; |
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 if we took a page out of the table api (hah!) and took in some like a searchProvider object instead. We could default it to a client side version, but provide a server implementation in other places.
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.
oh god. let me check
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.
That sounds complicated. Can we do it with just may be a searchMode
enum (Implicit and external)? I think eventually, we would have a separate basic filter multi select component, but we need this as a stepping stone.
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.
OK looked at multiselect - the search provider wouldn't work as well because the data is actually coming in as content children vs an array like some of the other components, so an output is the only way that comes to mind to accomplish this - but let's clean up the ambiguity between the two enable search inputs as you mentioned.
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.
so does this look good?
@Input()
public enableSearch: boolean = false;
@Input()
public searchMode: MultiSelectSearchMode = MultiSelectSearchMode.Implicit;
...
export const enum MultiSelectSearchMode {
Implicit = 'implicit',
External = 'external'
}
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'd rather boil down another input and make the enum values more explicit, but same idea:
@Input()
public searchMode: MultiSelectSearchMode = MultiSelectSearchMode.Disabled;
@Output
public searchValueChange: EventEmitter<string> = new EventEmitter<string>();
...
export const enum MultiSelectSearchMode {
Disabled = 'disabled', // Search is not available
CaseInsensitive = 'case-insensitive', // Current available values are filtered in a case insensitive way and an emit is triggered
EmitOnly = 'emit-only' // Current available values not filtered, but an emit still triggered
}
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.
Cool.
This comment has been minimized.
This comment has been minimized.
if (this.searchMode === MultiSelectSearchMode.CaseInsensitive) { | ||
this.searchSubject.next(searchText); | ||
|
||
return; |
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 case should still emit. There's no harm in doing so - it could be useful for a component's consumer to know when the search has changed. I'd expect that from a lib component and here it's actually more complex to avoid. Also, it says so in the enum 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.
I missed the comment. I think this can be confusing. Until there is a known use case, I think we should not emit for this mode since filtering is applied internally. That's why i was keeping Implicit
as it's 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.
I would prefer calling it Implicit for now and keep the emit logic as above.
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 part do you find confusing? A component is expected to emit when its state changes - the caller decides whether they care or not.
The name implicit really doesn't indicate anything to the caller - it just says that something is not directly expressed. But since we're directly expressing that, why not have it describe what it's actually doing?
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.
If search is happening implicitly then why emit on the search value. As a consumer am I supposed to act on it? The name case-insensitive
doesn't convey well that there is a auto filtering applied
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 am fine with that name, but with that name I don't think we should emit. Can we keep the same name but add the emit logic after we have a valid use case?
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.
The reason I'm caught up on this is that it's not that we're omitting something until we need it - that, I'm pretty much always for. Here, we're adding extra logic to make the behavior of an output inconsistent until we need to use it. In that case, I'd much rather have consistency even if we're not always using it. Outputs are meant to tell you about a state change, in this case, it's telling us that the search string has changed - the host is the one deciding whether to do anything with that or not.
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.
oh come on :)
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.
updated
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.
you're my hero!
<ng-container *ngIf="this.searchMode !== '${MultiSelectSearchMode.Disabled}'"> | ||
<ng-container *ngIf="this.allOptions$ | async as allOptions"> | ||
<ng-container *ngIf="allOptions.length > 5"> | ||
<ng-container *ngIf="this.searchMode === '${MultiSelectSearchMode.EmitOnly}' || allOptions.length > 5"> |
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 condition is non obvious to me - the two search modes don't really dictate when the search box should or should be shown - I'd think it would be either the same logic for both, or no logic and let the caller dictate by explicitly disabling filter if they're not providing 5+ options (can't remember where exactly that conversation landed in the previous PR).
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.
That problem comes up when you search and get less than 5 results. You are stuck at that point. We can't do it with an option, since this logic will not work with server side search.
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.
That's actually why I'd rather take the logic out entirely - if I express a search mode, show it. If I want to hide the search box in certain conditions, that's trivially done on the caller side.
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.
The only thing is, for consistent behavior we will have to put searchMode= options.length > 5 ? MultiSelectSearchMode.Implicit : MultiSelectSearchMode.Disabled
in every usage. It looks really weird to show search with just 1 option.
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.
There's very places where we have a variable number of options, anyway - and I think with any static small number (such as 6) search doesn't really make sense.
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.
We need the options.length > 1 logic for displaying buttons 'select all' and 'clear selected' buttons. I can remove allOptions.length > 5
conditions if you feel it is not useful and condition is non obvious.
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.
Removed
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…trace/hypertrace-ui into multi-select-support-server-search
Description
Please include a summary of the change, motivation and context.
Testing
Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.
Checklist:
Documentation
Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.