mirror of
https://github.com/stashapp/stash.git
synced 2026-01-29 03:22:53 +01:00
Fix empty sort by causing UI crash (#1480)
This commit is contained in:
parent
ad0a9d0707
commit
2469012008
2 changed files with 7 additions and 6 deletions
|
|
@ -499,7 +499,9 @@ export const ListFilter: React.FC<IListFilterProps> = (
|
|||
|
||||
<Dropdown as={ButtonGroup} className="mr-2">
|
||||
<Dropdown.Toggle split variant="secondary" id="more-menu">
|
||||
{intl.formatMessage({ id: currentSortBy?.messageID })}
|
||||
{currentSortBy
|
||||
? intl.formatMessage({ id: currentSortBy.messageID })
|
||||
: ""}
|
||||
</Dropdown.Toggle>
|
||||
<Dropdown.Menu className="bg-secondary text-white">
|
||||
{renderSortByOptions()}
|
||||
|
|
|
|||
|
|
@ -450,11 +450,9 @@ const useList = <QueryResult extends IQueryResult, QueryData extends IDataItem>(
|
|||
const originalPathName = useRef(location.pathname);
|
||||
const persistanceKey = options.persistanceKey ?? options.filterMode;
|
||||
|
||||
const defaultSort = options.defaultSort ?? filterOptions.defaultSortBy;
|
||||
const [filter, setFilter] = useState<ListFilterModel>(
|
||||
new ListFilterModel(
|
||||
queryString.parse(location.search),
|
||||
options.defaultSort ?? filterOptions.defaultSortBy
|
||||
)
|
||||
new ListFilterModel(queryString.parse(location.search), defaultSort)
|
||||
);
|
||||
|
||||
const updateInterfaceConfig = useCallback(
|
||||
|
|
@ -515,7 +513,7 @@ const useList = <QueryResult extends IQueryResult, QueryData extends IDataItem>(
|
|||
}
|
||||
: activeFilter;
|
||||
|
||||
const newFilter = new ListFilterModel(query);
|
||||
const newFilter = new ListFilterModel(query, defaultSort);
|
||||
|
||||
// Compare constructed filter with current filter.
|
||||
// If different it's the result of navigation, and we update the filter.
|
||||
|
|
@ -531,6 +529,7 @@ const useList = <QueryResult extends IQueryResult, QueryData extends IDataItem>(
|
|||
history.replace(newLocation);
|
||||
}
|
||||
}, [
|
||||
defaultSort,
|
||||
filter,
|
||||
interfaceState.data,
|
||||
interfaceState.loading,
|
||||
|
|
|
|||
Loading…
Reference in a new issue