Skip to content

Commit 74368a5

Browse files
(Lookup): show listHeader and listFooter consistently
1 parent 2bc8eab commit 74368a5

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

src/scripts/Lookup.tsx

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -699,26 +699,28 @@ const LookupDropdown: FC<LookupDropdownProps> = ({
699699
const dropdownClassNames = classnames(
700700
'slds-dropdown',
701701
'slds-dropdown_length-with-icon-7',
702-
'slds-dropdown_fluid'
702+
'slds-dropdown_fluid',
703+
'slds-scrollable_none'
703704
);
704705

705706
return (
706707
<div
707708
id={listboxId}
708709
className={dropdownClassNames}
710+
style={{ maxHeight: RESET_MAX_HEIGHT }}
709711
role='listbox'
710712
aria-label='Search Results'
711713
tabIndex={0}
712714
aria-busy={loading}
713715
ref={dropdownRef}
714716
>
715-
<ul
716-
className='slds-listbox slds-listbox_vertical'
717-
role='presentation'
718-
onKeyDown={onKeyDown}
719-
onBlur={onBlur}
720-
>
721-
{listHeader ? (
717+
{listHeader ? (
718+
<ul
719+
className='slds-listbox slds-listbox_vertical'
720+
role='presentation'
721+
onKeyDown={onKeyDown}
722+
onBlur={onBlur}
723+
>
722724
<li role='presentation' className='slds-listbox__item'>
723725
<div
724726
id={getOptionId(listHeaderIdSeed)}
@@ -731,7 +733,15 @@ const LookupDropdown: FC<LookupDropdownProps> = ({
731733
{listHeader}
732734
</div>
733735
</li>
734-
) : null}
736+
</ul>
737+
) : null}
738+
<ul
739+
className='slds-listbox slds-listbox_vertical slds-scrollable_y'
740+
style={{ maxHeight: MAIN_LIST_BOX_MAX_HEIGHT }}
741+
role='presentation'
742+
onKeyDown={onKeyDown}
743+
onBlur={onBlur}
744+
>
735745
{filteredData.map((entry) => (
736746
<LookupOption
737747
key={entry.value}
@@ -749,24 +759,35 @@ const LookupDropdown: FC<LookupDropdownProps> = ({
749759
</div>
750760
</li>
751761
) : null}
752-
{listFooter ? (
762+
</ul>
763+
{listFooter ? (
764+
<ul
765+
className='slds-listbox slds-listbox_vertical'
766+
role='presentation'
767+
onKeyDown={onKeyDown}
768+
onBlur={onBlur}
769+
>
753770
<li role='presentation' className='slds-listbox__item'>
754771
<div
755772
id={getOptionId(listFooterIdSeed)}
756-
className='slds-media slds-media_center slds-listbox__option slds-listbox__option_entity'
773+
className='slds-media slds-media_center slds-listbox__option slds-listbox__option_entity slds-listbox__option_term'
757774
role='option'
758775
tabIndex={0}
759776
onFocus={() => onOptionFocus(listFooterIdSeed)}
760777
>
761778
{listFooter}
762779
</div>
763780
</li>
764-
) : null}
765-
</ul>
781+
</ul>
782+
) : null}
766783
</div>
767784
);
768785
};
769786

787+
// manually replaces where `max-height` is specified
788+
const RESET_MAX_HEIGHT = 'unset';
789+
const MAIN_LIST_BOX_MAX_HEIGHT = 'calc((1.5rem + 1rem) * 7)'; // copied from `.slds-dropdown_length-with-icon-7`
790+
770791
/**
771792
*
772793
*/

0 commit comments

Comments
 (0)