Skip to content

Commit

Permalink
fix: add proxy display prop to prevent primereact multiselect bug
Browse files Browse the repository at this point in the history
  • Loading branch information
slhr committed Sep 19, 2024
1 parent d120c02 commit 86f44d6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/MultiSelect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ export const MultiSelect = React.forwardRef(({
const hasFilter = filter ?? shouldFilterSelectOptions(options)
const dataAttributes = pickDataAttributes(props)

const proxyDisplay = () => {
const isChip = display === "chip"

if (isChip) {
// eslint-disable-next-line
console.warn(`The "display" prop value has been replaced with "comma"
to avoid incorrect behavior caused by a bug in the primereact library.
issue: https://github.com/primefaces/primereact/issues/7125`)
}

return isChip ? "comma" : display
}

const onFooterButtonClick = newValue => {
const newEvent = {
target: { name, value: newValue, id },
Expand Down Expand Up @@ -151,7 +164,7 @@ export const MultiSelect = React.forwardRef(({
disabled={disabled}
selectedItemsLabel={selectedItemsLabel}
showClear={showClear}
display={display}
display={proxyDisplay()}
overlayVisible={overlayVisible}
removeIcon={removeIcon()}
tooltip={tooltip}
Expand Down

0 comments on commit 86f44d6

Please sign in to comment.