web: expand parent FormGroup when containing element has error

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-08-21 15:24:31 +02:00
parent bff7addb55
commit 00a666856d

View file

@ -5,6 +5,7 @@ import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import AKGlobal from "../../authentik.css";
import { t } from "@lingui/macro";
import { FormGroup } from "./FormGroup";
@customElement("ak-form-element-horizontal")
export class HorizontalFormElement extends LitElement {
@ -43,8 +44,20 @@ export class HorizontalFormElement extends LitElement {
@property()
errorMessage = "";
_invalid = false;
@property({ type: Boolean })
invalid = false;
set invalid(v: boolean) {
this._invalid = v;
// check if we're in a form group, and expand that form group
const parent = this.parentElement?.parentElement;
if (parent && "expanded" in parent) {
(parent as FormGroup).expanded = true;
}
}
get invalid(): boolean {
return this._invalid;
}
@property()
name = "";