Skip to content

Commit

Permalink
Fix primefaces#6995: Key should be reference on element and not spread
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Aug 6, 2024
1 parent 72bc4d4 commit 8dd04da
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
7 changes: 5 additions & 2 deletions components/lib/autocomplete/AutoCompletePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,18 @@ export const AutoCompletePanel = React.memo(
const itemGroupProps = mergeProps(
{
index,
key: key ? key : null,
className: cx('itemGroup'),
'data-p-highlight': false,
...labelItemProps
},
_ptm('itemGroup')
);

return <li {...itemGroupProps}>{content}</li>;
return (
<li {...itemGroupProps} key={key ? key : null}>
{content}
</li>
);
};

const createListItem = (item, key, index, listItemProps) => {
Expand Down
10 changes: 4 additions & 6 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3587,8 +3587,7 @@ export const Calendar = React.memo(
const dates = createDates(monthMetaData, groupIndex);
const containerProps = mergeProps(
{
className: cx('container'),
key: UniqueComponentId('calendar_container_')
className: cx('container')
},
ptm('container')
);
Expand All @@ -3605,7 +3604,7 @@ export const Calendar = React.memo(

return (
currentView === 'date' && (
<div {...containerProps}>
<div {...containerProps} key={UniqueComponentId('calendar_container_')}>
<table {...tableProps}>
<thead {...tableHeaderProps}>
<tr {...tableHeaderRowProps}>{dayNames}</tr>
Expand Down Expand Up @@ -3635,15 +3634,14 @@ export const Calendar = React.memo(

const headerProps = mergeProps(
{
className: cx('header'),
key: index
className: cx('header')
},
ptm('header')
);

return (
<div {...groupProps} key={monthKey}>
<div {...headerProps}>
<div {...headerProps} key={index}>
{header}
{backwardNavigator}
{title}
Expand Down
10 changes: 5 additions & 5 deletions components/lib/chip/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const Chip = React.memo(

const removeIconProps = mergeProps(
{
key: 'removeIcon',
role: 'button',
tabIndex: 0,
className: cx('removeIcon'),
Expand All @@ -56,7 +55,6 @@ export const Chip = React.memo(
if (props.image) {
const imageProps = mergeProps(
{
key: 'image',
src: props.image,
onError: props.onImageError
},
Expand All @@ -67,7 +65,6 @@ export const Chip = React.memo(
} else if (props.icon) {
const chipIconProps = mergeProps(
{
key: 'icon',
className: cx('icon')
},
ptm('icon')
Expand All @@ -79,13 +76,16 @@ export const Chip = React.memo(
if (props.label) {
const labelProps = mergeProps(
{
key: 'label',
className: cx('label')
},
ptm('label')
);

content.push(<span {...labelProps}>{props.label}</span>);
content.push(
<span {...labelProps} key="label">
{props.label}
</span>
);
}

if (props.removable) {
Expand Down
3 changes: 1 addition & 2 deletions components/lib/chips/Chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ export const Chips = React.memo(
const icon = createRemoveIcon(value, index);
const tokenProps = mergeProps(
{
key: `${index}_${value}`,
id: props.inputId + '_chips_item_' + index,
role: 'option',
'aria-label': value,
Expand All @@ -364,7 +363,7 @@ export const Chips = React.memo(
);

return (
<li {...tokenProps}>
<li {...tokenProps} key={`${index}_${value}`}>
{label}
{icon}
</li>
Expand Down
7 changes: 5 additions & 2 deletions components/lib/tabmenu/TabMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ export const TabMenu = React.memo(
{
ref: tabsRef.current[`tab_${index}`],
id: key,
key,
onKeyDown: (event) => onKeyDownItem(event, item, index),
className: cx('menuitem', { _className, active, disabled }),
style: style,
Expand All @@ -296,7 +295,11 @@ export const TabMenu = React.memo(
getPTOptions('menuitem', item, index)
);

return <li {...menuItemProps}>{content}</li>;
return (
<li {...menuItemProps} key={key}>
{content}
</li>
);
};

const createItems = () => {
Expand Down

0 comments on commit 8dd04da

Please sign in to comment.