Skip to content

Commit 05042d3

Browse files
committed
feat: rename menuAlign prop in select picker
1 parent 9d453bb commit 05042d3

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/Shared/Components/SelectPicker/SelectPicker.component.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const SelectPicker = ({
127127
showSelectedOptionsCount = false,
128128
menuSize,
129129
variant = SelectPickerVariantType.DEFAULT,
130-
menuAlignToRight = false,
130+
shouldMenuAlignRight = false,
131131
...props
132132
}: SelectPickerProps) => {
133133
const { inputId, required, isDisabled } = props
@@ -142,9 +142,9 @@ const SelectPicker = ({
142142
size,
143143
menuSize,
144144
variant,
145-
menuAlignToRight,
145+
shouldMenuAlignRight,
146146
}),
147-
[error, size, menuSize, variant],
147+
[error, size, menuSize, variant, shouldMenuAlignRight],
148148
)
149149

150150
const renderControl = useCallback(

src/Shared/Components/SelectPicker/type.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,11 @@ export interface SelectPickerProps
123123
* @default false
124124
*/
125125
disableDescriptionEllipsis?: boolean
126-
menuAlignToRight?: boolean
126+
/**
127+
* If true, the menu is aligned at the right end to prevent going outside of viewport
128+
* in case of menu being larger than the control
129+
*
130+
* @default false
131+
*/
132+
shouldMenuAlignRight?: boolean
127133
}

src/Shared/Components/SelectPicker/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ export const getCommonSelectStyle = ({
5858
size,
5959
menuSize,
6060
variant,
61-
menuAlignToRight,
61+
shouldMenuAlignRight,
6262
}: Pick<
6363
SelectPickerProps,
64-
'error' | 'size' | 'menuSize' | 'variant' | 'menuAlignToRight'
64+
'error' | 'size' | 'menuSize' | 'variant' | 'shouldMenuAlignRight'
6565
>): StylesConfig<SelectPickerOptionType> => ({
6666
container: (base, state) => ({
6767
...base,
@@ -80,7 +80,9 @@ export const getCommonSelectStyle = ({
8080
width: getMenuWidthFromSize(menuSize),
8181
zIndex: 'var(--select-picker-menu-index)',
8282
...(getVariantOverrides(variant)?.menu(base, state) || {}),
83-
...(menuAlignToRight ? { right: 0 } : {}),
83+
...(shouldMenuAlignRight && {
84+
right: 0,
85+
}),
8486
}),
8587
menuList: (base) => ({
8688
...base,

0 commit comments

Comments
 (0)