fix(ui): handles falsey relationship options on reset (#8095)

This commit is contained in:
Jacob Fletcher
2024-09-06 12:55:09 -04:00
committed by GitHub
parent 0688c2b79d
commit f9ae56ec88

View File

@@ -29,15 +29,18 @@ const sortOptions = (options: Option[]): Option[] =>
export const optionsReducer = (state: OptionGroup[], action: Action): OptionGroup[] => {
switch (action.type) {
case 'CLEAR': {
const exemptValues = Array.isArray(action.exemptValues)
? action.exemptValues
: [action.exemptValues]
const exemptValues = action.exemptValues
? Array.isArray(action.exemptValues)
? action.exemptValues
: [action.exemptValues]
: []
const clearedStateWithExemptValues = state.filter((optionGroup) => {
const clearedOptions = optionGroup.options.filter((option) => {
if (exemptValues) {
return exemptValues.some((exemptValue) => {
return (
exemptValue &&
option.value === (typeof exemptValue === 'object' ? exemptValue.value : exemptValue)
)
})