Skip to content

Commit

Permalink
[4366] Fix a warning for an autocomplete widget
Browse files Browse the repository at this point in the history
Bug: #4366
Signed-off-by: Denis Nikiforov <[email protected]>
  • Loading branch information
AresEkb committed Jan 7, 2025
1 parent 3f2ad65 commit 155d610
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This may have some consequences for downstream applications which are embedding
=== Bug fixes

- https://github.com/eclipse-sirius/sirius-web/issues/4282[#4282] [diagram] Fixed a warning on the frontend about non-unique GraphQL fragment name
- https://github.com/eclipse-sirius/sirius-web/issues/4366[#4366] [form] Fix a warning for an autocomplete widget

=== New Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,23 @@ export const ReferencePreview = ({ widget }: PreviewWidgetProps) => {
value={options}
disableClearable
renderTags={(value, getTagProps) =>
value.map(({ label, iconURL }, index) => (
<Chip
classes={{ label: classes.referenceValueStyle }}
label={label}
data-testid={`reference-value-${label}`}
icon={
<div>
<IconOverlay iconURL={[iconURL]} alt={''} />
</div>
}
{...getTagProps({ index })}
/>
))
value.map(({ label, iconURL }, index) => {
const { key, ...tagProps } = getTagProps({ index });
return (
<Chip
key={key}
classes={{ label: classes.referenceValueStyle }}
label={label}
data-testid={`reference-value-${label}`}
icon={
<div>
<IconOverlay iconURL={[iconURL]} alt={''} />
</div>
}
{...tagProps}
/>
);
})
}
renderInput={(params) => (
<TextField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export const ValuedReferenceAutocomplete = ({
isOptionEqualToValue={(option, value) => option.id === value.id}
onChange={handleAutocompleteChange}
renderOption={(props: HTMLAttributes<HTMLLIElement>, option: GQLReferenceValue) => (
<li {...props}>
<li {...props} key={option.id}>
<IconOverlay iconURL={option.iconURL} alt={option.kind} />
<span className={classes.optionLabel} data-testid={`option-${option.label}`}>
{option.label}
Expand All @@ -244,21 +244,25 @@ export const ValuedReferenceAutocomplete = ({
)}
disableClearable
renderTags={(value, getTagProps) =>
value.map((option, index) => (
<Chip
classes={{ label: classes.referenceValueStyle }}
label={option.label}
data-testid={`reference-value-${option.label}`}
icon={
<div>
<IconOverlay iconURL={option.iconURL} alt={option.kind} />
</div>
}
clickable={!readOnly && !widget.readOnly}
onClick={() => optionClickHandler(option)}
{...getTagProps({ index })}
/>
))
value.map((option, index) => {
const { key, ...tagProps } = getTagProps({ index });
return (
<Chip
key={key}
classes={{ label: classes.referenceValueStyle }}
label={option.label}
data-testid={`reference-value-${option.label}`}
icon={
<div>
<IconOverlay iconURL={option.iconURL} alt={option.kind} />
</div>
}
clickable={!readOnly && !widget.readOnly}
onClick={() => optionClickHandler(option)}
{...tagProps}
/>
);
})
}
renderInput={(params) => (
<TextField
Expand Down

0 comments on commit 155d610

Please sign in to comment.