Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 83084ac

Browse files
authored
Merge pull request #152 from PrashantkumarWebDeveloper/patch-1
Make item icons optional
2 parents 5958c7d + df6b8a2 commit 83084ac

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

‎src/main/default/classes/LookupSearchResult.cls‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public virtual class LookupSearchResult implements Comparable {
1515
/**
1616
* @param id the lookup entry identifier (generally a record ID)
1717
* @param sObjectType Optional - The sObject type of the selected record. This value is not used for lookup rendering. It's passed back to the selection handler in case you search on multiple object types.
18-
* @param icon Optional - A qualified SLDS icon name taken from https://www.lightningdesignsystem.com/icons. It defaults to standard:default.
18+
* @param icon Optional - A qualified SLDS icon name taken from https://www.lightningdesignsystem.com/icons. No icon is displayed by default.
1919
* @param title Required - The label of the lookup entry
2020
* @param subtitle Optional - A subtitle that is displayed under the lookup entry label
2121
*/

‎src/main/default/lwc/lookup/lookup.html‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<div class={getComboboxClass} role="none">
1818
<template lwc:if={isSingleEntry}>
1919
<lightning-icon
20+
lwc:if={getSelectIconName}
2021
icon-name={getSelectIconName}
2122
size="small"
2223
alternative-text="Selected item icon"
@@ -106,7 +107,10 @@
106107
onclick={handleResultClick}
107108
data-recordid={item.result.id}
108109
>
109-
<span class="slds-media__figure slds-listbox__option-icon">
110+
<span
111+
class="slds-media__figure slds-listbox__option-icon"
112+
lwc:if={item.result.icon}
113+
>
110114
<lightning-icon
111115
icon-name={item.result.icon}
112116
size="small"
@@ -193,7 +197,7 @@
193197
onremove={handleRemoveSelectedItem}
194198
name={item.id}
195199
>
196-
<lightning-icon icon-name={item.icon}></lightning-icon>
200+
<lightning-icon icon-name={item.icon}lwc:if={item.icon}></lightning-icon>
197201
</lightning-pill>
198202
</li>
199203
</template>

‎src/main/default/lwc/lookup/lookup.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ export default class Lookup extends NavigationMixin(LightningElement) {
104104
result.titleFormatted = result.title;
105105
result.subtitleFormatted = result.subtitle;
106106
}
107-
// Add icon if missing
108-
if (typeof result.icon === 'undefined') {
109-
result.icon = 'standard:default';
110-
}
111107
return result;
112108
});
113109
// Add local state and dynamic class to search results
@@ -414,7 +410,10 @@ export default class Lookup extends NavigationMixin(LightningElement) {
414410
if (this.isMultiEntry) {
415411
css += 'slds-input-has-icon_right';
416412
} else {
417-
css += this.hasSelection() ? 'slds-input-has-icon_left-right' : 'slds-input-has-icon_right';
413+
css +=
414+
this.hasSelection() && this._curSelection[0].icon
415+
? 'slds-input-has-icon_left-right'
416+
: 'slds-input-has-icon_right';
418417
}
419418
return css;
420419
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /