-
Notifications
You must be signed in to change notification settings - Fork 11
feat: show selected item's icon in trigger label if applicable #884
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
Changes from 3 commits
89b8f27
b30f50d
4f23fc9
cfcbda3
1b69a18
b8f0dc3
3aa2e25
fd47b9c
16983c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -55,7 +55,13 @@ import { SelectSize } from './select-size'; | |||||
| class="trigger-content menu-with-border" | ||||||
| [ngClass]="[this.justifyClass]" | ||||||
| > | ||||||
| <ht-icon *ngIf="this.icon" class="trigger-prefix-icon" [icon]="this.icon" [size]="this.iconSize"> | ||||||
| <ht-icon | ||||||
| *ngIf="this.getPrefixIcon | htMemoize: selected:this.icon" | ||||||
arjunlalb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| class="trigger-prefix-icon" | ||||||
| [icon]="this.getPrefixIcon | htMemoize: selected:this.icon" | ||||||
| [size]="this.iconSize" | ||||||
| [color]="this.getPrefixIconColor | htMemoize: selected" | ||||||
| > | ||||||
| </ht-icon> | ||||||
| <ht-label class="trigger-label" [label]="selected?.selectedLabel || selected?.label || this.placeholder"> | ||||||
| </ht-label> | ||||||
|
|
@@ -204,6 +210,27 @@ export class SelectComponent<V> implements AfterContentInit, OnChanges { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| public getPrefixIcon( | ||||||
| selectedOption: SelectOptionComponent<V> | undefined, | ||||||
| triggerIcon: string | undefined | ||||||
| ): string | undefined { | ||||||
| if (selectedOption !== undefined && selectedOption?.icon !== undefined) { | ||||||
|
||||||
| if (selectedOption !== undefined && selectedOption?.icon !== undefined) { | |
| if (selectedOption?.icon !== undefined) { |
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 there's a selection, we should show the selection's icon or nothing.
If there's no selection, show the trigger icon. That's the intent.
It doesn't make sense to show the regular trigger icon along with a selection. that would be confusing.
we already show selected label in the trigger the same way. This is extending it to the icon as well.
Fixed the logic.
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 my brain wasn't functioning last night when I wrote the logic for this. 🤔
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.
Using the selected icon if defined makes sense, but not using the component wide icon if the selections aren't individually... iconized breaks the original intent. I think it's just two different styles:

in this one, that icon just is meant to apply to every option, but not appear as a duplicate in the option list.
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.
is there a reason to use debug element querying rather than spectator querying ? is it because spectator doesn't give you access to the component on root queries?
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.
yep. wanted to access component to verify the contents of it.