-
Notifications
You must be signed in to change notification settings - Fork 34
Labels
Description
Info and Code
Issue reported by Sven Luedemann
Using this code in React:
import { GoabDropdown, GoabDropdownItem, GoabFormItem } from "@abgov/react-components";
import { GoabDropdownOnChangeDetail } from "@abgov/ui-components-common";
import { useState } from "react";
export function DropdownRoute() {
const parents = ["One", "Two", "Three"];
const childrenOne = ["Alpha", "Beta"];
const childrenTwo = ["Alpha", "Beta", "Gamma"];
const childrenThree = ["Alpha", "Gamma"];
const [children, setChildren] = useState<string[]>([]);
const loadSchemas = (details: GoabDropdownOnChangeDetail) => {
if (typeof details.value === "string") {
if (details.value === "One") setChildren(childrenOne);
else if (details.value === "Two") setChildren(childrenTwo);
else setChildren(childrenThree);
}
};
const log = () => {
console.log("Children Changed");
};
return (
<main>
<GoabFormItem label="Parent" requirement="optional">
<GoabDropdown name="parent" placeholder="Select a value" onChange={loadSchemas}>
{parents.map((parent) => (
<GoabDropdownItem key={parent} value={parent} label={parent} />
))}
</GoabDropdown>
</GoabFormItem>
<GoabFormItem label="Children" requirement="optional">
<GoabDropdown name="children" placeholder="Select a value" onChange={log}>
{children.map((child, index) => (
<GoabDropdownItem key={child} value={child} label={child} />
))}
</GoabDropdown>
</GoabFormItem>
</main>
);
}And following these steps:
- Select Option 1
- Select Option 2
- Select Option 3
- Select Option 2
- Notice that the order of items in the Dropdown doesn't reflect the order of items in the
childrenTwovariable
Acceptance Criteria:
- Order of items in a Dropdown should be the order provided in code
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
🔖 Ready