Fixed actor count filter showing 1 when none are available, fixed search input not submitting on enter on mobile.
This commit is contained in:
@@ -35,18 +35,22 @@ const dragging = ref({});
|
||||
const sliders = computed(() => rows.map((row) => {
|
||||
const filter = props.filters[row.key];
|
||||
const buckets = props.counts?.[row.key] || [];
|
||||
const countMax = buckets.at(-1)?.value ?? sliderCap; // buckets are sorted by value
|
||||
// at least 1 to keep the slider usable, and never below the active filter so its handles stay in view
|
||||
const max = Math.max(1, Math.min(countMax, sliderCap), filter?.min ?? 0, filter?.max ?? 0);
|
||||
const value = [filter?.min ?? 0, filter?.max ?? max];
|
||||
// buckets are sorted by value; without aggregations at all, fall back to the full slider
|
||||
const countMax = props.counts ? (buckets.at(-1)?.value ?? 0) : sliderCap;
|
||||
// nothing above 0 to filter for, e.g. no trans performers in any matching scene; an active filter keeps it usable so it can be reset
|
||||
const isEmpty = countMax < 1 && !filter;
|
||||
// collapsed to 0 when empty, otherwise at least 1 so the slider has somewhere to go, and never below the active filter so its handles stay in view
|
||||
const max = isEmpty ? 0 : Math.max(1, Math.min(countMax, sliderCap), filter?.min ?? 0, filter?.max ?? 0);
|
||||
const value = isEmpty ? [0, 0] : [filter?.min ?? 0, filter?.max ?? max];
|
||||
|
||||
return {
|
||||
...row,
|
||||
max,
|
||||
isEmpty,
|
||||
isCapped: countMax > max,
|
||||
value,
|
||||
display: dragging.value[row.key] || value,
|
||||
mountKey: `${row.key}-${max}-${value.join('-')}`, // remount when the range or filter changes, the slider only reads its value on mount
|
||||
mountKey: `${row.key}-${max}-${value.join('-')}-${isEmpty}`, // remount when the range or filter changes, the slider only reads its value on mount
|
||||
};
|
||||
}));
|
||||
|
||||
@@ -90,6 +94,7 @@ function updateRange(slider, [min, max], reload) {
|
||||
:min="0"
|
||||
:max="slider.max"
|
||||
:value="slider.value"
|
||||
:disabled="slider.isEmpty"
|
||||
:allow-enable="false"
|
||||
@input="(range) => updateRange(slider, range, false)"
|
||||
@change="(range) => updateRange(slider, range, true)"
|
||||
|
||||
Reference in New Issue
Block a user