mirror of
https://github.com/keycloak/keycloak.git
synced 2026-02-03 20:39:33 -05:00
Fix SearchDropdown clear button and URI search in Authorization tabs (#45407)
- Add defaultValues to useForm for proper form reset - Call reset(defaultValues) in Clear button handler - Fix form field name from 'uris' to 'uri' to match API parameter - Add missing 'reset' dependency to useEffect Closes #45406 Signed-off-by: erenkan <eren@keymate.io>
This commit is contained in:
parent
b0f93232e9
commit
5ad68321f6
1 changed files with 16 additions and 4 deletions
|
|
@ -30,6 +30,15 @@ type SearchDropdownProps = {
|
|||
type: "resource" | "policy" | "permission";
|
||||
};
|
||||
|
||||
const defaultValues: SearchForm = {
|
||||
name: "",
|
||||
type: "",
|
||||
uri: "",
|
||||
owner: "",
|
||||
scope: "",
|
||||
resource: "",
|
||||
};
|
||||
|
||||
export const SearchDropdown = ({
|
||||
types,
|
||||
search,
|
||||
|
|
@ -37,7 +46,7 @@ export const SearchDropdown = ({
|
|||
type,
|
||||
}: SearchDropdownProps) => {
|
||||
const { t } = useTranslation();
|
||||
const form = useForm<SearchForm>({ mode: "onChange" });
|
||||
const form = useForm<SearchForm>({ mode: "onChange", defaultValues });
|
||||
const {
|
||||
reset,
|
||||
formState: { isDirty },
|
||||
|
|
@ -51,7 +60,7 @@ export const SearchDropdown = ({
|
|||
onSearch(form);
|
||||
};
|
||||
|
||||
useEffect(() => reset(search), [search]);
|
||||
useEffect(() => reset(search), [search, reset]);
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
|
|
@ -80,7 +89,7 @@ export const SearchDropdown = ({
|
|||
{type === "resource" && (
|
||||
<>
|
||||
<TextControl name="type" label={t("type")} />
|
||||
<TextControl name="uris" label={t("uris")} />
|
||||
<TextControl name="uri" label={t("uris")} />
|
||||
<TextControl name="owner" label={t("owner")} />
|
||||
</>
|
||||
)}
|
||||
|
|
@ -116,7 +125,10 @@ export const SearchDropdown = ({
|
|||
<Button
|
||||
variant="link"
|
||||
data-testid="revert-btn"
|
||||
onClick={() => onSearch({})}
|
||||
onClick={() => {
|
||||
reset(defaultValues);
|
||||
onSearch({});
|
||||
}}
|
||||
>
|
||||
{t("clear")}
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue