Skip to content

Commit

Permalink
chore: useSortDropdown内のselect用optionsの生成ロジックを整理
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM committed Jan 21, 2025
1 parent 689f5be commit fd60537
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,23 @@ export const useSortDropdown = ({ sortFields, defaultOrder, onApply, decorators
(e) => {
const select = e.currentTarget
const newLabel = select.options[select.selectedIndex].label
const newFields = innerFields.map((field) => ({
...field,
selected: field.label === newLabel,
}))
const newFields = innerFields.map((field) => {
if (field.label === newLabel) {
if (!field.selected) {
return {
...field,
selected: true,
}
}
} else if (field.selected) {
return {
...field,
selected: false,
}
}

return field
})

setInnerFields(newFields)
setInnerSelectedField(newLabel)
Expand Down

0 comments on commit fd60537

Please sign in to comment.