Skip to content

Commit bd0f9f9

Browse files
committed
feat: reset license text
- ensure that the license text is reset whenever a new license expression is selected - reset does not occur if a new license expression is typed instead of selected from the available options - new behavior prevents accidental mismatches between expression and text Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
1 parent 74ebf1e commit bd0f9f9

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

.husky/commit-msg

-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@
55
#
66
# SPDX-License-Identifier: Apache-2.0
77

8-
. "$(dirname -- "$0")/_/husky.sh"
9-
108
yarn commitlint --edit ${1}

src/Frontend/Components/AttributionForm/PackageAutocomplete/PackageAutocomplete.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function PackageAutocomplete({
129129
}, [attributeValue, inputValue]);
130130

131131
return (
132-
<Autocomplete
132+
<Autocomplete<PackageInfo, false, true, true>
133133
title={title}
134134
disabled={disabled}
135135
readOnly={readOnly}
@@ -200,6 +200,20 @@ export function PackageAutocomplete({
200200
secondary: (option) =>
201201
typeof option === 'string' ? option : generatePurl(option),
202202
}}
203+
onChange={(_, value) =>
204+
typeof value !== 'string' &&
205+
value[attribute] !== packageInfo[attribute] &&
206+
onEdit?.(() => {
207+
dispatch(
208+
setTemporaryDisplayPackageInfo({
209+
...packageInfo,
210+
[attribute]: value[attribute],
211+
...(attribute === 'licenseName' ? { licenseText: '' } : null),
212+
wasPreferred: undefined,
213+
}),
214+
);
215+
})
216+
}
203217
onInputChange={(event, value) =>
204218
event &&
205219
packageInfo[attribute] !== value &&

src/Frontend/Components/Autocomplete/Autocomplete.tsx

+17-15
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,27 @@ export function Autocomplete<
187187
]).length
188188
}
189189
size={'small'}
190-
InputLabelProps={getInputLabelProps()}
191190
inputRef={ref}
192-
inputProps={{
193-
'aria-label': props['aria-label'],
194-
sx: {
195-
overflowX: 'hidden',
196-
textOverflow: 'ellipsis',
197-
'&::placeholder': {
198-
opacity: 1,
191+
slotProps={{
192+
input: {
193+
startAdornment: startAdornment || renderStartAdornment(),
194+
endAdornment: renderEndAdornment(),
195+
readOnly,
196+
sx,
197+
...(variant === 'filled' && { disableUnderline: true }),
198+
},
199+
inputLabel: getInputLabelProps(),
200+
htmlInput: {
201+
'aria-label': props['aria-label'],
202+
sx: {
203+
overflowX: 'hidden',
204+
textOverflow: 'ellipsis',
205+
'&::placeholder': {
206+
opacity: 1,
207+
},
199208
},
200209
},
201210
}}
202-
InputProps={{
203-
startAdornment: startAdornment || renderStartAdornment(),
204-
endAdornment: renderEndAdornment(),
205-
readOnly,
206-
sx,
207-
...(variant === 'filled' && { disableUnderline: true }),
208-
}}
209211
onKeyDown={(event) => {
210212
// https://github.com/mui/material-ui/issues/21129
211213
event.key === 'Backspace' && event.stopPropagation();

0 commit comments

Comments
 (0)