Skip to content

Commit 2fe7fbe

Browse files
feat(MultiSelect): new hideLabel prop (#9840)
* feat(MultiSelect): new hideLabel prop * feat(FilterableMultiSelect): new hideLabel prop - Add `hideLabel` prop to the filterable MultiSelect to make it consistant with the default MultiSelect. - Fix up `PublicAPI-test.js.snap` file using command `yarn test packages/react/__tests__/PublicAPI-test.js -u`. First the file was restored to commit 3e0231d, then the `yarn test` was used to make changes to `PublicAPI-test.js.snap`. - Fix format issue (spaces) in MultiSelect.js Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 9f558cf commit 2fe7fbe

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,6 +3246,9 @@ Map {
32463246
],
32473247
"type": "shape",
32483248
},
3249+
"hideLabel": Object {
3250+
"type": "bool",
3251+
},
32493252
"id": Object {
32503253
"isRequired": true,
32513254
"type": "string",
@@ -4209,6 +4212,9 @@ Map {
42094212
],
42104213
"type": "shape",
42114214
},
4215+
"hideLabel": Object {
4216+
"type": "bool",
4217+
},
42124218
"id": Object {
42134219
"isRequired": true,
42144220
"type": "string",
@@ -4453,6 +4459,9 @@ Map {
44534459
],
44544460
"type": "shape",
44554461
},
4462+
"hideLabel": Object {
4463+
"type": "bool",
4464+
},
44564465
"id": Object {
44574466
"isRequired": true,
44584467
"type": "string",

packages/react/src/components/MultiSelect/FilterableMultiSelect.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export default class FilterableMultiSelect extends React.Component {
5151
*/
5252
downshiftProps: PropTypes.shape(Downshift.propTypes),
5353

54+
/**
55+
* Specify whether the title text should be hidden or not
56+
*/
57+
hideLabel: PropTypes.bool,
58+
5459
/**
5560
* Specify a custom `id`
5661
*/
@@ -299,6 +304,7 @@ export default class FilterableMultiSelect extends React.Component {
299304
itemToElement,
300305
itemToString,
301306
titleText,
307+
hideLabel,
302308
helperText,
303309
type,
304310
initialSelectedItems,
@@ -350,6 +356,7 @@ export default class FilterableMultiSelect extends React.Component {
350356
const titleClasses = cx({
351357
[`${prefix}--label`]: true,
352358
[`${prefix}--label--disabled`]: disabled,
359+
[`${prefix}--visually-hidden`]: hideLabel,
353360
});
354361
const helperClasses = cx({
355362
[`${prefix}--form__helper-text`]: true,

packages/react/src/components/MultiSelect/MultiSelect-story.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const directions = {
7171
const props = () => ({
7272
id: text('MultiSelect ID (id)', 'carbon-multiselect-example'),
7373
titleText: text('Title (titleText)', 'Multiselect title'),
74+
hideLabel: boolean('No title text shown (hideLabel)', false),
7475
helperText: text('Helper text (helperText)', 'This is helper text'),
7576
disabled: boolean('Disabled (disabled)', false),
7677
light: boolean('Light variant (light)', false),

packages/react/src/components/MultiSelect/MultiSelect.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const MultiSelect = React.forwardRef(function MultiSelect(
4444
itemToElement,
4545
itemToString,
4646
titleText,
47+
hideLabel,
4748
helperText,
4849
label,
4950
type,
@@ -142,6 +143,7 @@ const MultiSelect = React.forwardRef(function MultiSelect(
142143
);
143144
const titleClasses = cx(`${prefix}--label`, {
144145
[`${prefix}--label--disabled`]: disabled,
146+
[`${prefix}--visually-hidden`]: hideLabel,
145147
});
146148
const helperId = !helperText
147149
? undefined
@@ -349,6 +351,11 @@ MultiSelect.propTypes = {
349351
*/
350352
downshiftProps: PropTypes.shape(Downshift.propTypes),
351353

354+
/**
355+
* Specify whether the title text should be hidden or not
356+
*/
357+
hideLabel: PropTypes.bool,
358+
352359
/**
353360
* Specify a custom `id`
354361
*/

0 commit comments

Comments
 (0)