Skip to content

Commit 4bedf39

Browse files
authored
Merge pull request #844 from devtron-labs/fix/rjsf-select
fix: RJSF select picker menuPortalTarget issue
2 parents ec40ca6 + 3da4da9 commit 4bedf39

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
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": "1.18.1-pre-7",
3+
"version": "1.18.1-pre-8",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

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)