@@ -14,7 +14,7 @@ import React, {
14
14
FC ,
15
15
} from 'react' ;
16
16
import classnames from 'classnames' ;
17
- import { AutoAlign } from './AutoAlign' ;
17
+ import { AutoAlign , AutoAlignInjectedProps } from './AutoAlign' ;
18
18
import { Button } from './Button' ;
19
19
import { FormElement , FormElementProps } from './FormElement' ;
20
20
import { Icon , IconCategory } from './Icon' ;
@@ -181,22 +181,31 @@ const LookupSelectedState: FC<LookupSelectedStateProps> = ({
181
181
*/
182
182
type LookupScopeSelectorContainerProps = {
183
183
scopeListboxId : string ;
184
- autoAlignContentRef : Ref < HTMLElement | null > ;
185
184
children : React . ReactNode ;
186
- } ;
185
+ } & AutoAlignInjectedProps ;
187
186
188
187
/**
189
188
* Container component for scope selector dropdown with AutoAlign
190
189
*/
191
190
const LookupScopeSelectorContainer : FC < LookupScopeSelectorContainerProps > = ( {
192
191
scopeListboxId,
193
- autoAlignContentRef,
194
192
children,
193
+ alignment,
194
+ autoAlignContentRef,
195
195
} ) => {
196
+ const [ vertAlign , align ] = alignment ;
197
+ const dropdownClassNames = classnames (
198
+ 'slds-dropdown' ,
199
+ vertAlign ? `slds-dropdown_${ vertAlign } ` : undefined ,
200
+ align ? `slds-dropdown_${ align } ` : undefined ,
201
+ 'slds-dropdown_length-with-icon-7' ,
202
+ 'slds-dropdown_fluid'
203
+ ) ;
204
+
196
205
return (
197
206
< div
198
207
id = { scopeListboxId }
199
- className = 'react-slds-lookup-dropdown slds-dropdown slds-dropdown_length-with-icon-7 slds-dropdown_fluid'
208
+ className = { dropdownClassNames }
200
209
role = 'listbox'
201
210
aria-label = 'Scope Options'
202
211
ref = { useMergeRefs ( [ autoAlignContentRef ] ) }
@@ -424,10 +433,10 @@ const LookupScopeSelector: FC<LookupScopeSelectorProps> = ({
424
433
alignmentStyle = 'menu'
425
434
portalClassName = { portalClassName }
426
435
>
427
- { ( { autoAlignContentRef } ) => (
436
+ { ( injectedProps ) => (
428
437
< LookupScopeSelectorContainer
429
438
scopeListboxId = { scopeListboxId }
430
- autoAlignContentRef = { autoAlignContentRef }
439
+ { ... injectedProps }
431
440
>
432
441
< ul
433
442
className = 'slds-listbox slds-listbox_vertical'
@@ -668,9 +677,8 @@ type LookupDropdownContainerProps = {
668
677
listboxId : string ;
669
678
loading ?: boolean ;
670
679
dropdownRef : Ref < HTMLDivElement > ;
671
- autoAlignContentRef : Ref < HTMLElement | null > ;
672
680
children : React . ReactNode ;
673
- } ;
681
+ } & AutoAlignInjectedProps ;
674
682
675
683
/**
676
684
* Container component for dropdown with merged refs
@@ -679,13 +687,25 @@ const LookupDropdownContainer: FC<LookupDropdownContainerProps> = ({
679
687
listboxId,
680
688
loading,
681
689
dropdownRef,
682
- autoAlignContentRef,
683
690
children,
691
+ alignment,
692
+ autoAlignContentRef,
684
693
} ) => {
694
+ const [ vertAlign , align ] = alignment ;
695
+ const dropdownClassNames = classnames (
696
+ 'react-slds-lookup-dropdown-main' ,
697
+ 'slds-dropdown' ,
698
+ vertAlign ? `slds-dropdown_${ vertAlign } ` : undefined ,
699
+ align ? `slds-dropdown_${ align } ` : undefined ,
700
+ 'slds-dropdown_length-with-icon-7' ,
701
+ 'slds-dropdown_fluid' ,
702
+ 'slds-scrollable_none'
703
+ ) ;
704
+
685
705
return (
686
706
< div
687
707
id = { listboxId }
688
- className = 'react-slds-lookup-dropdown react-slds-lookup-dropdown-main slds-dropdown slds-dropdown_length-with-icon-7 slds-dropdown_fluid slds-scrollable_none'
708
+ className = { dropdownClassNames }
689
709
role = 'listbox'
690
710
aria-label = 'Search Results'
691
711
tabIndex = { 0 }
@@ -748,12 +768,12 @@ const LookupDropdown: FC<LookupDropdownProps> = ({
748
768
alignmentStyle = 'menu'
749
769
portalClassName = { portalClassName }
750
770
>
751
- { ( { autoAlignContentRef } ) => (
771
+ { ( injectedProps ) => (
752
772
< LookupDropdownContainer
753
773
listboxId = { listboxId }
754
774
loading = { loading }
755
775
dropdownRef = { dropdownRef }
756
- autoAlignContentRef = { autoAlignContentRef }
776
+ { ... injectedProps }
757
777
>
758
778
{ listHeader ? (
759
779
< ul
@@ -857,7 +877,6 @@ function useInitComponentStyle() {
857
877
'.react-slds-lookup-scope-down-icon-container .react-slds-lookup-scope-down-icon' ,
858
878
'{ width: 0.8rem; height: 0.8rem; }' ,
859
879
] ,
860
- [ '.react-slds-lookup-dropdown' , '{ left: 0; transform: translateX(0); }' ] ,
861
880
[
862
881
'.react-slds-lookup-dropdown-main' ,
863
882
`{ max-height: ${ LIST_PARENT_MAX_HEIGHT } ; min-width: 15rem; }` ,
0 commit comments