@@ -199,11 +199,7 @@ export default class Lookup extends NavigationMixin(LightningElement) {
199199 if ( this . isMultiEntry ) {
200200 return true ;
201201 }
202- return ! this . hasSelection ( ) ;
203- }
204-
205- hasSelection ( ) {
206- return this . _curSelection . length > 0 ;
202+ return ! this . hasSelection ;
207203 }
208204
209205 processSelectionUpdate ( isUserInteraction ) {
@@ -214,7 +210,7 @@ export default class Lookup extends NavigationMixin(LightningElement) {
214210 // Indicate that component was interacted with
215211 this . _isDirty = isUserInteraction ;
216212 // Blur input after single select lookup selection
217- if ( ! this . isMultiEntry && this . hasSelection ( ) ) {
213+ if ( ! this . isMultiEntry && this . hasSelection ) {
218214 this . _hasFocus = false ;
219215 }
220216 // If selection was changed by user, notify parent components
@@ -246,7 +242,7 @@ export default class Lookup extends NavigationMixin(LightningElement) {
246242 // Indicate that component was interacted with
247243 this . _isDirty = true ;
248244 // Blur input after single select lookup selection
249- if ( ! this . isMultiEntry && this . hasSelection ( ) ) {
245+ if ( ! this . isMultiEntry && this . hasSelection ) {
250246 this . _hasFocus = false ;
251247 }
252248 // Notify parent components that selection was cleared
@@ -382,14 +378,23 @@ export default class Lookup extends NavigationMixin(LightningElement) {
382378 ) ;
383379 }
384380
381+ get hasSelection ( ) {
382+ return this . _curSelection . length > 0 ;
383+ }
384+
385385 get hasResults ( ) {
386386 return this . _searchResults . length > 0 ;
387387 }
388388
389389 get getFormElementClass ( ) {
390- return this . variant === VARIANT_LABEL_INLINE
391- ? 'slds-form-element slds-form-element_horizontal'
392- : 'slds-form-element' ;
390+ let css = 'slds-form-element' ;
391+ if ( this . variant === VARIANT_LABEL_INLINE ) {
392+ css += ' slds-form-element_horizontal' ;
393+ }
394+ if ( this . _errors . length > 0 || ( this . _isDirty && this . required && ! this . hasSelection ) ) {
395+ css += ' slds-has-error' ;
396+ }
397+ return css ;
393398 }
394399
395400 get getLabelClass ( ) {
@@ -398,14 +403,6 @@ export default class Lookup extends NavigationMixin(LightningElement) {
398403 : 'slds-form-element__label' ;
399404 }
400405
401- get getContainerClass ( ) {
402- let css = 'slds-combobox_container ' ;
403- if ( this . _errors . length > 0 ) {
404- css += 'has-custom-error' ;
405- }
406- return css ;
407- }
408-
409406 get getDropdownClass ( ) {
410407 let css = 'slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click ' ;
411408 if ( this . isListboxOpen ) {
@@ -419,11 +416,8 @@ export default class Lookup extends NavigationMixin(LightningElement) {
419416 if ( this . _hasFocus && this . hasResults ) {
420417 css += 'slds-has-focus ' ;
421418 }
422- if ( this . _errors . length > 0 || ( this . _isDirty && this . required && ! this . hasSelection ( ) ) ) {
423- css += 'has-custom-error ' ;
424- }
425419 if ( ! this . isMultiEntry ) {
426- css += 'slds-combobox__input-value ' + ( this . hasSelection ( ) ? 'has-custom-border' : '' ) ;
420+ css += 'slds-combobox__input-value ' + ( this . hasSelection ? 'has-custom-border' : '' ) ;
427421 }
428422 return css ;
429423 }
@@ -434,7 +428,7 @@ export default class Lookup extends NavigationMixin(LightningElement) {
434428 css += 'slds-input-has-icon_right' ;
435429 } else {
436430 css +=
437- this . hasSelection ( ) && this . _curSelection [ 0 ] . icon
431+ this . hasSelection && this . _curSelection [ 0 ] . icon
438432 ? 'slds-input-has-icon_left-right'
439433 : 'slds-input-has-icon_right' ;
440434 }
@@ -444,38 +438,38 @@ export default class Lookup extends NavigationMixin(LightningElement) {
444438 get getSearchIconClass ( ) {
445439 let css = 'slds-input__icon slds-input__icon_right ' ;
446440 if ( ! this . isMultiEntry ) {
447- css += this . hasSelection ( ) ? 'slds-hide' : '' ;
441+ css += this . hasSelection ? 'slds-hide' : '' ;
448442 }
449443 return css ;
450444 }
451445
452446 get getClearSelectionButtonClass ( ) {
453447 return (
454448 'slds-button slds-button_icon slds-input__icon slds-input__icon_right ' +
455- ( this . hasSelection ( ) ? '' : 'slds-hide' )
449+ ( this . hasSelection ? '' : 'slds-hide' )
456450 ) ;
457451 }
458452
459453 get getSelectIconName ( ) {
460- return this . hasSelection ( ) ? this . _curSelection [ 0 ] . icon : 'standard:default' ;
454+ return this . hasSelection ? this . _curSelection [ 0 ] . icon : 'standard:default' ;
461455 }
462456
463457 get getSelectIconClass ( ) {
464- return 'slds-combobox__input-entity-icon ' + ( this . hasSelection ( ) ? '' : 'slds-hide' ) ;
458+ return 'slds-combobox__input-entity-icon ' + ( this . hasSelection ? '' : 'slds-hide' ) ;
465459 }
466460
467461 get getInputValue ( ) {
468462 if ( this . isMultiEntry ) {
469463 return this . _searchTerm ;
470464 }
471- return this . hasSelection ( ) ? this . _curSelection [ 0 ] . title : this . _searchTerm ;
465+ return this . hasSelection ? this . _curSelection [ 0 ] . title : this . _searchTerm ;
472466 }
473467
474468 get getInputTitle ( ) {
475469 if ( this . isMultiEntry ) {
476470 return '' ;
477471 }
478- return this . hasSelection ( ) ? this . _curSelection [ 0 ] . title : '' ;
472+ return this . hasSelection ? this . _curSelection [ 0 ] . title : '' ;
479473 }
480474
481475 get getListboxClass ( ) {
@@ -490,6 +484,6 @@ export default class Lookup extends NavigationMixin(LightningElement) {
490484 if ( this . isMultiEntry ) {
491485 return false ;
492486 }
493- return this . hasSelection ( ) ;
487+ return this . hasSelection ;
494488 }
495489}
0 commit comments