diff --git a/.all-contributorsrc b/.all-contributorsrc index 120a3bf13b05..dbca2e54ae1e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -646,6 +646,15 @@ "contributions": [ "code" ] + }, + { + "login": "molyholy", + "name": "molyholy", + "avatar_url": "https://avatars2.githubusercontent.com/u/77503726?v=4", + "profile": "https://github.com/molyholy", + "contributions": [ + "code" + ] } ], "commitConvention": "none" diff --git a/README.md b/README.md index 49d72eaf5a85..3aa8af37f05d 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
DavidSCChen

💻 +
molyholy

💻 diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 18d12911597d..96f9df4e065f 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -2309,6 +2309,9 @@ Map { ], "type": "oneOfType", }, + "hideLabel": Object { + "type": "bool", + }, "id": Object { "isRequired": true, "type": "string", diff --git a/packages/react/src/components/Dropdown/Dropdown-story.js b/packages/react/src/components/Dropdown/Dropdown-story.js index 351c66447651..bf55f87e8ca8 100644 --- a/packages/react/src/components/Dropdown/Dropdown-story.js +++ b/packages/react/src/components/Dropdown/Dropdown-story.js @@ -60,6 +60,7 @@ const props = () => ({ disabled: boolean('Disabled (disabled)', false), light: boolean('Light variant (light)', false), titleText: text('Title (titleText)', 'Dropdown label'), + hideLabel: boolean('No title text shown (hideLabel)', false), helperText: text('Helper text (helperText)', 'This is some helper text.'), invalid: boolean('Show form validation UI (invalid)', false), invalidText: text( diff --git a/packages/react/src/components/Dropdown/Dropdown.js b/packages/react/src/components/Dropdown/Dropdown.js index 6547e6b9b91c..ad3828dcfc2d 100644 --- a/packages/react/src/components/Dropdown/Dropdown.js +++ b/packages/react/src/components/Dropdown/Dropdown.js @@ -45,6 +45,7 @@ const Dropdown = React.forwardRef(function Dropdown( onChange, id, titleText, + hideLabel, helperText, translateWithId, light, @@ -98,6 +99,7 @@ const Dropdown = React.forwardRef(function Dropdown( const titleClasses = cx(`${prefix}--label`, { [`${prefix}--label--disabled`]: disabled, + [`${prefix}--visually-hidden`]: hideLabel, }); const helperClasses = cx(`${prefix}--form__helper-text`, { @@ -232,6 +234,11 @@ Dropdown.propTypes = { */ helperText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), + /** + * Specify whether the title text should be hidden or not + */ + hideLabel: PropTypes.bool, + /** * Specify a custom `id` */