Skip to content

Commit a784e6c

Browse files
authored
Allow a Partial object for labels in MultiSelect (#2843)
## Summary: This allows consumers to decide which labels to override, as some may not be relevant and some may be deliberately left as their default values. ## Test plan: Verify types pass on stories and stories still render as expected Author: timmcca-be Reviewers: jandrade Required Reviewers: Approved By: jandrade Checks: ✅ 20 checks were successful, ⏭️ 4 checks have been skipped, ⏹️ 2 checks were cancelled Pull Request URL: #2843
1 parent c222990 commit a784e6c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

.changeset/sharp-pans-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/wonder-blocks-dropdown": minor
3+
---
4+
5+
Allow a `Partial` object for `labels` in `MultiSelect`, so consumers can decide which labels to override

__docs__/wonder-blocks-dropdown/multi-select.stories.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {LabelsValues} from "@khanacademy/wonder-blocks-dropdown";
1515
import ComponentInfo from "../components/component-info";
1616
import packageConfig from "../../packages/wonder-blocks-dropdown/package.json";
1717
import multiSelectArgtypes from "./multi-select.argtypes";
18-
import {defaultLabels} from "../../packages/wonder-blocks-dropdown/src/util/constants";
1918
import {
2019
allCountries,
2120
allProfilesWithPictures,
@@ -340,8 +339,7 @@ export const ControlledOpened: StoryComponentType = {
340339
};
341340

342341
// Custom MultiSelect labels
343-
const dropdownLabels: LabelsValues = {
344-
...defaultLabels,
342+
const dropdownLabels: Partial<LabelsValues> = {
345343
noneSelected: "Solar system",
346344
someSelected: (numSelectedValues: number) => `${numSelectedValues} planets`,
347345
};
@@ -651,7 +649,6 @@ export const ImplicitAllEnabled: StoryComponentType = {
651649
args: {
652650
implicitAllEnabled: true,
653651
labels: {
654-
...defaultLabels,
655652
someSelected: (numSelectedValues: number) =>
656653
`${numSelectedValues} fruits`,
657654
allSelected: "All planets selected",

packages/wonder-blocks-dropdown/src/components/multi-select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type Props = AriaProps &
132132
/**
133133
* The object containing the custom labels and placeholder values used inside this component.
134134
*/
135-
labels?: LabelsValues;
135+
labels?: Partial<LabelsValues>;
136136
/**
137137
* Callback for when the selection changes. Parameter is an updated array of
138138
* the values that are now selected.

0 commit comments

Comments
 (0)