diff --git a/packages/page-staking/src/Filtering.tsx b/packages/page-staking/src/Filtering.tsx index 1be70150eb..6ad13c6e0e 100644 --- a/packages/page-staking/src/Filtering.tsx +++ b/packages/page-staking/src/Filtering.tsx @@ -2,9 +2,11 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import React from 'react'; +import queryString from 'query-string'; +import React, { useEffect } from 'react'; import { Input, Toggle } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; +import { isString } from '@polkadot/util'; import { useTranslation } from './translate'; @@ -21,6 +23,16 @@ function Filtering ({ children, className, nameFilter, setNameFilter, setWithIde const { t } = useTranslation(); const { api } = useApi(); + // on load, parse the query string and extract the filter + useEffect((): void => { + const queryFilter = queryString.parse(location.href.split('?')[1]).filter; + + if (isString(queryFilter)) { + setNameFilter(queryFilter); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + return (