diff --git a/gradle/changelog/filter_on_pagination.yaml b/gradle/changelog/filter_on_pagination.yaml new file mode 100644 index 0000000000..3262afdabf --- /dev/null +++ b/gradle/changelog/filter_on_pagination.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Wrong redirect on paginated overviews ([#1535](https://github.com/scm-manager/scm-manager/pull/1535)) diff --git a/scm-ui/ui-components/src/OverviewPageActions.tsx b/scm-ui/ui-components/src/OverviewPageActions.tsx index 633bc07d52..da9a2437cd 100644 --- a/scm-ui/ui-components/src/OverviewPageActions.tsx +++ b/scm-ui/ui-components/src/OverviewPageActions.tsx @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import React, { FC } from "react"; +import React, { FC, useState } from "react"; import { useHistory, useLocation } from "react-router-dom"; import classNames from "classnames"; import { Button, DropDown, urls } from "./index"; @@ -50,6 +50,7 @@ const OverviewPageActions: FC = ({ }) => { const history = useHistory(); const location = useLocation(); + const [filterValue, setFilterValue] = useState(urls.getQueryStringFromLocation(location)); const groupSelector = groups && (
= ({ return null; }; + const filter = (filter: string) => { + if ((filter && filter !== filterValue) || (!filter && filterValue)) { + history.push(`/${link}/?q=${filter}`); + } else { + history.push(`${location.pathname}?q=${filter}`); + } + setFilterValue(filter); + }; + return (
{groupSelector} @@ -79,9 +89,7 @@ const OverviewPageActions: FC = ({ { - history.push(`/${link}/?q=${filter}`); - }} + filter={filter} testId={testId + "-filter"} />