added none option to attribute group (#4191)

* added none option

fixes: #4085

* small refactor
This commit is contained in:
Erik Jan de Wit 2023-01-16 08:17:00 +01:00 committed by GitHub
parent 5ba147b384
commit 4d44265ed0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 21 deletions

View file

@ -63,19 +63,15 @@ const LoginFlow = ({
aria-label={t(label)} aria-label={t(label)}
isOpen={open} isOpen={open}
> >
{/* The type for the children of Select are incorrect, so we need a fragment here. */} {[
{/* eslint-disable-next-line react/jsx-no-useless-fragment */} ...(defaultValue === ""
<> ? [
{defaultValue === "" && ( <SelectOption key="empty" value="">
<SelectOption key="empty" value={defaultValue}>
{t("common:none")} {t("common:none")}
</SelectOption> </SelectOption>,
)} ]
</> : []),
{/* The type for the children of Select are incorrect, so we need a fragment here. */} ...(flows?.map((option) => (
{/* eslint-disable-next-line react/jsx-no-useless-fragment */}
<>
{flows?.map((option) => (
<SelectOption <SelectOption
selected={option.alias === field.value} selected={option.alias === field.value}
key={option.id} key={option.id}
@ -83,8 +79,8 @@ const LoginFlow = ({
> >
{option.alias} {option.alias}
</SelectOption> </SelectOption>
))} )) || []),
</> ]}
</Select> </Select>
)} )}
/> />

View file

@ -145,14 +145,19 @@ export const AttributeGeneralSettings = () => {
onChange(value.toString()); onChange(value.toString());
setIsAttributeGroupDropdownOpen(false); setIsAttributeGroupDropdownOpen(false);
}} }}
selections={[value || t("common:choose")]} selections={[value || t("common:none")]}
variant={SelectVariant.single} variant={SelectVariant.single}
> >
{config?.groups?.map((group) => ( {[
<SelectOption key="empty" value="">
{t("common:none")}
</SelectOption>,
...(config?.groups?.map((group) => (
<SelectOption key={group.name} value={group.name}> <SelectOption key={group.name} value={group.name}>
{group.name} {group.name}
</SelectOption> </SelectOption>
))} )) || []),
]}
</Select> </Select>
)} )}
></Controller> ></Controller>