Skip to content

Commit

Permalink
Remove slider-related extensions when allowing decimal input
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Feb 24, 2024
1 parent 3a55c53 commit 2837892
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/components/Question/Question.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,22 @@ const Question = (props: QuestionProps): JSX.Element => {
: IQuestionnaireItemType.decimal;
dispatchUpdateItem(IItemProperty.type, newItemType)

// remove slider extension if toggling to decimal
// remove slider-related extensions if toggling decimals on, as sliders currently only support integers
if (newItemType === IQuestionnaireItemType.decimal) {
removeItemExtension(props.item, IExtentionType.itemControl, props.dispatch);
const extensionsToRemove = [
IExtentionType.itemControl,
IExtentionType.questionnaireSliderStepValue,
IExtentionType.minValue,
IExtentionType.maxValue
]
removeItemExtension(
props.item,
extensionsToRemove,
props.dispatch
);
}

// remove max decimal places extension if toggling off
// remove max decimal places extension if toggling decimals off
if (newItemType === IQuestionnaireItemType.integer) {
removeItemExtension(props.item, IExtentionType.maxDecimalPlaces, props.dispatch);
}
Expand Down Expand Up @@ -266,9 +276,19 @@ const Question = (props: QuestionProps): JSX.Element => {
}
};
if (!isSlider) {
setItemExtension(props.item, newExtension, props.dispatch)
setItemExtension(props.item, newExtension, props.dispatch);
} else {
removeItemExtension(props.item, IExtentionType.itemControl, props.dispatch)
const extensionsToRemove = [
IExtentionType.itemControl,
IExtentionType.questionnaireSliderStepValue,
IExtentionType.minValue,
IExtentionType.maxValue
]
removeItemExtension(
props.item,
extensionsToRemove,
props.dispatch
);
}
})}
/>
Expand Down

0 comments on commit 2837892

Please sign in to comment.