Skip to content

Commit b4b51ba

Browse files
authored
Merge pull request #217 from cnblogs/fix-uncheck-category
fix: unable to unselect category
2 parents 086f579 + 8461cbb commit b4b51ba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ui/post-cfg/components/select/CatSelect.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ export class CatSelect extends Component<Props, State> {
3232
useComboBoxAsMenuWidth
3333
onChange={(_, opt, __, val) => {
3434
if (opt !== undefined) {
35-
if (val === undefined) {
35+
if (opt.selected !== true || val === undefined) {
3636
const selectedCatIds = this.state.selectedCatIds.filter(x => x !== opt.data)
3737
this.setState({ selectedCatIds })
38+
this.props.onChange(selectedCatIds)
3839
} else {
3940
this.state.selectedCatIds.push(opt.data as number)
4041
this.setState(this.state)
42+
this.props.onChange(this.state.selectedCatIds)
4143
}
4244
}
43-
this.props.onChange(this.state.selectedCatIds)
4445
}}
4546
/>
4647
)

0 commit comments

Comments
 (0)