-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add icon to combo box #133
Conversation
Signed-off-by: Matt Provost <[email protected]>
I've called this out in the parent issue too, but i think we should not limit this to just the search icon, but rather any Oui Icon. even custom ones. |
@ashwin-pc can you provide a "why" on not limiting the icon? For an icon in the left placement in a search bar, I would find it confusing to be any other icon. Flexibility on the right and on input boxes I am a OK with , but since the function of this field is search, I am providing this guardrail to prevent a misleading user experience from being implemented (an icon on the left indicates what the purpose of the field is, which is to search) Would like to hear your perspective though! |
Its just my opinion, but i want the design system to offer me as much flexibility as possible while letting me do the right thing easily. By changing the property to simply If this change was perhaps tied to a search feature in the combobox, i'd be more okay with the limitation since adding a prop like |
@ashwin-pc - These are some good points about implementation. I did finally think of one case where I would agree the search icon would not be the appropriate choice - when a combobox is used to create custom tags and there are no pre-existing tags. Search in this case is invalid, and perhaps "plus" is more appropriate. I know this is getting into splitting some hairs. After some re-thinking and discussion, here are my updated thoughts to the approach of having the icon prop. I want engineering maintainers within the project to set the path for implementation and developer experience - so these are for consideration given the feedback in the comments. Approach 1:
Approach 2:
|
I like both approaches but i'd lean towards option 1.1 where we add an icon prop. But I dont think adding search by default is a good idea. It would mean that to disable an icon in a combobox, we would have to explicitly pass One other option would be to use the prop to define the purpose of the UI element. e.g. |
For clarity & my education (thanks for taking me on the journey) - we wouldn’t want two separate props 1) icon type and 2) show/hide icon
Vs icon = false?
@BSFishy any approach ideas here as well?
|
I would be supportive of:
|
@kgcreative I can get behind that. Still not 100% onboard with the need to have |
I think one conversation to have is which icon makes the most sense to be "default" icon. When I look at the list of glyphs, the ones that come to mind are |
@kgcreative can you provide cases for setting those other options as default - my main justification for setting the default to search it is the primary interaction within the input box - search to find a tag (object,data source,index, etc) or to search & receive no result in the case where custom tag is added. To match the current default of the input box and to not force a braking visual change the icon would not be visible by default. This allows UX & builders to determine the “correct” approach across various projects.
|
@KrooshalUX, I think we have a clear use case for search. @ashwin-pc , I would be curious to know if you're aware of any other use cases that would weigh us toward using a different icon vs |
I am having trouble imagining a form that has 5 combo-boxes, all with a search icon to their left. |
The intent is that a combo box with an icon be more an exception that the rule, but when adding an icon, often time the search icon is the most appropriate (for example for searching/ multi selecting an index, a field, or a tag) |
@kgcreative @KrooshalUX The primary concern i have with this is the API. having a boolean prop that simply shows a search icon is indicative of code smell. If as @AMoo-Miki said, the icon showed up during user input or when it active automatically, thats fine. Or if the prop allowed for arbitrary icons too, it seems like a good use of a prop, but simply using it to show or hide a single icon "search" seems wasteful and indicative that we havent abstracted the problem well. If we are doing this to not introduce a breaking change, thats something we should avoid since technically we can always find a solution does not break semver if we bend over backwards enough. But we should weigh that with the consequence of doing so. In this case its an API that serves a very specific usecase that imo can be solved without it. API changes are hard to walk back on so we should be careful when introducing them. |
@ashwin-pc I believe we have identified a path forward that satisfies your concerns. @BSFishy can you please follow up with the approach you are going to move forward with? Do we need to close this PR? |
No, I'll update this one. I think the way forward is making an |
yep that works for me :) |
Signed-off-by: Matt Provost <[email protected]>
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 rest of the PR looks good, just update the test to explicitly check for the Icon element
Signed-off-by: Matt Provost <[email protected]>
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 implementation looks good, but I think the props of the combo box are now confusing with two icon-related props that control different icons.
@@ -59,6 +60,7 @@ export interface OuiComboBoxInputProps<T> extends CommonProps { | |||
focusedOptionId?: string; | |||
fullWidth?: boolean; | |||
hasSelectedOptions: boolean; | |||
icon?: IconType | boolean; |
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 don't love that there's now both icon
and noIcon
props - it's confusing to reason about what should happen if those are in disagreement. Without reading through the source code it, would be confusing to know what would happen if ...icon="true" noIcon="true"...
. I understand if this change is meant to be backwards compatible. But for a PR that targets main
, I'd expect us to deprecate noIcon
in favor of icon
.
let icon; | ||
if (!!iconProp) { | ||
const iconClasses = classNames('ouiComboBoxPill', 'ouiComboBoxIcon'); | ||
|
||
icon = ( | ||
<OuiIcon | ||
type={typeof iconProp === 'string' ? iconProp : 'search'} | ||
size={compressed ? 's' : 'm'} | ||
className={iconClasses} | ||
data-test-subj="comboBoxIcon" | ||
/> | ||
); | ||
} |
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.
nit - you can avoid using let
by rewriting as a function.
if (!noIcon) { | ||
icon = { | ||
formControlIcon = { |
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 change now makes it clear that noIcon
and icon
properties refer to different icons. Updating the name of noIcon
to noFormControlIcon
or noToggleIcon
might be more descriptive.
* Add search icon to combo box Signed-off-by: Matt Provost <[email protected]> * Change from search icon to generic icon Signed-off-by: Matt Provost <[email protected]> * Update tests Signed-off-by: Matt Provost <[email protected]> --------- Signed-off-by: Matt Provost <[email protected]> Co-authored-by: Miki <[email protected]> (cherry picked from commit 4658c95)
* Add search icon to combo box Signed-off-by: Matt Provost <[email protected]> * Change from search icon to generic icon Signed-off-by: Matt Provost <[email protected]> * Update tests Signed-off-by: Matt Provost <[email protected]> --------- Signed-off-by: Matt Provost <[email protected]> Co-authored-by: Miki <[email protected]> (cherry picked from commit 4658c95) Co-authored-by: Matt Provost <[email protected]> Co-authored-by: Sean Neumann <[email protected]>
Description
Add a search icon prop to the combo box
Issues Resolved
#130
Check List
yarn lint
yarn test-unit
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.