Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(slider): fix slider click event bug #1034

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/slider/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default defineComponent({
const secondButtonRef = ref<SliderButtonType>();

const sliderState = reactive({
prevValue: 0 as SliderValue,
// TODO: 该属性应该是暴露出来的api供用户配置才对
showSteps: false,
});
const firstValue = ref(formatSlderValue(sliderValue.value, 'first'));
Expand Down Expand Up @@ -173,7 +173,7 @@ export default defineComponent({
if (props.range) {
changeValue = [firstValue.value, secondValue.value];
} else {
changeValue = sliderState.prevValue;
changeValue = firstValue.value;
}
}
const fixValue: SliderValue = setValues(changeValue);
Expand All @@ -199,15 +199,13 @@ export default defineComponent({
firstValue.value = props.min || 0;
secondValue.value = props.max || 100;
}
sliderState.prevValue = [firstValue.value, secondValue.value];
valuetext = `${firstValue.value}-${secondValue.value}`;
} else {
if (typeof sliderValue.value !== 'number') {
firstValue.value = props.min;
} else {
firstValue.value = Math.min(props.max, Math.max(props.min, sliderValue.value as number));
}
sliderState.prevValue = firstValue.value;
valuetext = String(firstValue.value);
}
if (sliderContainerRef.value) {
Expand Down Expand Up @@ -330,10 +328,9 @@ export default defineComponent({
const renderInputNumber = useSliderInput(inputConfig);

const renderInputButton = (): VNode => {
const firstInputVal = props.range ? firstValue.value : (sliderState.prevValue as number);
const firstInputVal = firstValue.value;
const firstInputOnChange = (v: number) => {
firstValue.value = v;
props.range ? (firstValue.value = v) : (sliderState.prevValue = v);
};
const secondInputVal = secondValue.value;
const secondInputOnChange = (v: number) => {
Expand Down