parent
f5282fbc75
commit
57b52309f0
2 changed files with 11 additions and 3 deletions
|
@ -4,6 +4,7 @@ import {
|
|||
ReactNode,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
@ -207,6 +208,7 @@ export function KeycloakDataTable<T>({
|
|||
const [max, setMax] = useState(10);
|
||||
const [first, setFirst] = useState(0);
|
||||
const [search, setSearch] = useState<string>("");
|
||||
const prevSearch = useRef<string>();
|
||||
|
||||
const [key, setKey] = useState(0);
|
||||
const refresh = () => setKey(new Date().getTime());
|
||||
|
@ -297,8 +299,15 @@ export function KeycloakDataTable<T>({
|
|||
useFetch(
|
||||
async () => {
|
||||
setLoading(true);
|
||||
const newSearch = prevSearch.current === "" && search !== "";
|
||||
|
||||
if (newSearch) {
|
||||
setFirst(0);
|
||||
}
|
||||
prevSearch.current = search;
|
||||
return typeof loader === "function"
|
||||
? unPaginatedData || (await loader(first, max + 1, search))
|
||||
? unPaginatedData ||
|
||||
(await loader(newSearch ? 0 : first, max + 1, search))
|
||||
: loader;
|
||||
},
|
||||
(data) => {
|
||||
|
|
|
@ -24,8 +24,7 @@ public abstract class RoleMappingResource {
|
|||
public final List<ClientRole> mapping(Predicate<RoleModel> predicate, long first, long max, final String search) {
|
||||
|
||||
return mapping(predicate).filter(clientRole -> clientRole.getClient().contains(search) || clientRole.getRole().contains(search))
|
||||
|
||||
.skip("".equals(search) ? first : 0).limit(max).collect(Collectors.toList());
|
||||
.skip(first).limit(max).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public RoleMappingResource(RealmModel realm, AdminPermissionEvaluator auth) {
|
||||
|
|
Loading…
Reference in a new issue