Skip to content

Commit 7c8508d

Browse files
(Picklist): add useInitComponentStyle()
1 parent 9bef1d0 commit 7c8508d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/scripts/Picklist.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { FormElement, FormElementProps } from './FormElement';
1717
import { Icon } from './Icon';
1818
import { AutoAlign } from './AutoAlign';
1919
import { DropdownMenuProps } from './DropdownMenu';
20-
import { isElInChildren } from './util';
20+
import { registerStyle, isElInChildren } from './util';
2121
import { ComponentSettingsContext } from './ComponentSettings';
2222
import { useControlledValue, useEventCallback, useMergeRefs } from './hooks';
2323
import { createFC } from './common';
@@ -150,6 +150,20 @@ const PicklistContext = createContext<{
150150
optionIdPrefix: '',
151151
});
152152

153+
/**
154+
*
155+
*/
156+
function useInitComponentStyle() {
157+
useEffect(() => {
158+
registerStyle('picklist', [
159+
[
160+
'.react-slds-picklist-dropdown',
161+
'{ left: 0; transform: translateX(0); }',
162+
],
163+
]);
164+
}, []);
165+
}
166+
153167
/**
154168
*
155169
*/
@@ -225,6 +239,8 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
225239
...rprops
226240
} = props;
227241

242+
useInitComponentStyle();
243+
228244
const fallbackId = useId();
229245
const id = id_ ?? fallbackId;
230246
const listboxId = `${id}-listbox`;
@@ -528,6 +544,7 @@ export const Picklist: (<MultiSelect extends boolean | undefined>(
528544
}
529545
);
530546
const dropdownClassNames = classnames(
547+
'react-slds-picklist-dropdown',
531548
'slds-dropdown',
532549
'slds-dropdown_length-5',
533550
menuSize ? `slds-dropdown_${menuSize}` : 'slds-dropdown_fluid'

0 commit comments

Comments
 (0)