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: Inoperable dashboard filter slider when range is <= 1 #27271

Merged
merged 3 commits into from
Feb 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@
}
}, [enableSingleExactValue]);

const MIN_NUM_STEPS = 20;
const stepHeuristic = (min: number, max: number) => {
const maxStepSize = (max - min) / MIN_NUM_STEPS;

Check warning on line 305 in superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx

View check run for this annotation

Codecov / codecov/patch

superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx#L305

Added line #L305 was not covered by tests
// normalizedStepSize: .06 -> .01, .003 -> .001
const normalizedStepSize = `1E${Math.floor(Math.log10(maxStepSize))}`;
return Math.min(1, parseFloat(normalizedStepSize));

Check warning on line 308 in superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx

View check run for this annotation

Codecov / codecov/patch

superset-frontend/src/filters/components/Range/RangeFilterPlugin.tsx#L307-L308

Added lines #L307 - L308 were not covered by tests
};

const step = max - min <= 1 ? stepHeuristic(min, max) : 1;

return (
<FilterPluginStyle height={height} width={width}>
{Number.isNaN(Number(min)) || Number.isNaN(Number(max)) ? (
Expand All @@ -323,6 +333,7 @@
<AntdSlider
min={min}
max={max}
step={step}
value={minMax[maxIndex]}
tipFormatter={tipFormatter}
marks={marks}
Expand All @@ -335,6 +346,7 @@
validateStatus={filterState.validateStatus}
min={min}
max={max}
step={step}
value={minMax[minIndex]}
tipFormatter={tipFormatter}
marks={marks}
Expand All @@ -346,6 +358,7 @@
<AntdSlider
min={min}
max={max}
step={step}
included={false}
value={minMax[minIndex]}
tipFormatter={tipFormatter}
Expand All @@ -359,6 +372,7 @@
range
min={min}
max={max}
step={step}
value={minMax}
onAfterChange={handleAfterChange}
onChange={handleChange}
Expand Down
Loading