Skip to content

Commit 087f837

Browse files
author
Amrit Kashyap Borah
committed
fix: select picker menuPortalTarget in rjsf
1 parent ec40ca6 commit 087f837

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/Common/RJSF/widgets/Select.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { PLACEHOLDERS, RJSF_FORM_SELECT_PORTAL_TARGET_ID } from '../constants'
1919

2020
import { deepEqual } from '@Common/Helper'
2121
import { SelectPicker } from '@Shared/Components'
22+
import { useEffect, useState } from 'react'
23+
import { getUniqueId } from '@Shared/Helpers'
2224

2325
export const SelectWidget = (props: WidgetProps) => {
2426
const {
@@ -42,13 +44,22 @@ export const SelectWidget = (props: WidgetProps) => {
4244
onChange(multiple ? option.map((o) => o.value) : option.value)
4345
}
4446

47+
const [key, setKey] = useState<string>()
48+
49+
useEffect(() => {
50+
// NOTE: need to trigger a re-render after re-mount since react-select
51+
// has an issue with menuPortalTarget after re-mounting
52+
setKey(getUniqueId(8))
53+
}, [])
54+
4555
const getOption = (value) =>
4656
multiple
4757
? selectOptions.filter((option) => value.some((val) => deepEqual(val, option.value)))
4858
: selectOptions.find((option) => deepEqual(value, option.value))
4959

5060
return (
5161
<SelectPicker
62+
key={key}
5263
inputId={`devtron-rjsf-select__${id}`}
5364
name={id}
5465
isMulti={multiple}

0 commit comments

Comments
 (0)