Skip to content

Commit 82d0b43

Browse files
authored
Merge pull request #253 from devtron-labs/feat/select-menu-alignment
feat: add support to align menu to right in select picker
2 parents 9625b82 + 29dc502 commit 82d0b43

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.2.10",
3+
"version": "0.2.11",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const SelectPicker = ({
127127
showSelectedOptionsCount = false,
128128
menuSize,
129129
variant = SelectPickerVariantType.DEFAULT,
130+
shouldMenuAlignRight = false,
130131
...props
131132
}: SelectPickerProps) => {
132133
const { inputId, required, isDisabled } = props
@@ -141,8 +142,9 @@ const SelectPicker = ({
141142
size,
142143
menuSize,
143144
variant,
145+
shouldMenuAlignRight,
144146
}),
145-
[error, size, menuSize, variant],
147+
[error, size, menuSize, variant, shouldMenuAlignRight],
146148
)
147149

148150
const renderControl = useCallback(

src/Shared/Components/SelectPicker/type.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export enum SelectPickerVariantType {
4141

4242
type SelectProps = ReactSelectProps<SelectPickerOptionType>
4343

44-
// TODO: Add support for border less
4544
export interface SelectPickerProps
4645
extends Pick<
4746
SelectProps,
@@ -124,4 +123,11 @@ export interface SelectPickerProps
124123
* @default false
125124
*/
126125
disableDescriptionEllipsis?: 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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ export const getCommonSelectStyle = ({
5858
size,
5959
menuSize,
6060
variant,
61-
}: Pick<SelectPickerProps, 'error' | 'size' | 'menuSize' | 'variant'>): StylesConfig<SelectPickerOptionType> => ({
61+
shouldMenuAlignRight,
62+
}: Pick<
63+
SelectPickerProps,
64+
'error' | 'size' | 'menuSize' | 'variant' | 'shouldMenuAlignRight'
65+
>): StylesConfig<SelectPickerOptionType> => ({
6266
container: (base, state) => ({
6367
...base,
6468
...(state.isDisabled && {
@@ -76,6 +80,9 @@ export const getCommonSelectStyle = ({
7680
width: getMenuWidthFromSize(menuSize),
7781
zIndex: 'var(--select-picker-menu-index)',
7882
...(getVariantOverrides(variant)?.menu(base, state) || {}),
83+
...(shouldMenuAlignRight && {
84+
right: 0,
85+
}),
7986
}),
8087
menuList: (base) => ({
8188
...base,

src/Shared/Hooks/UseDownload/UseDownload.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ const useDownload = () => {
4242
downloadSuccessToastContent = 'Downloaded Successfully',
4343
}: HandleDownloadProps): Promise<Error | ServerErrors> => {
4444
setIsDownloading(true)
45-
if (showFilePreparingToast) {
46-
toast.info(
47-
<ToastBody
48-
title="Preparing file for download"
49-
subtitle="File will be downloaded when it is available."
50-
/>,
51-
)
52-
}
5345
try {
5446
const response = await getDownloadResponse(downloadUrl)
5547
if (response.status === API_STATUS_CODES.OK) {
48+
if (showFilePreparingToast) {
49+
toast.info(
50+
<ToastBody
51+
title="Preparing file for download"
52+
subtitle="File will be downloaded when it is available."
53+
/>,
54+
)
55+
}
5656
const data = await (response as any).blob()
5757

5858
// Create a new URL object

0 commit comments

Comments
 (0)