Skip to content

Commit

Permalink
Merge pull request #690 from strapi/enh/required-combobox
Browse files Browse the repository at this point in the history
Pass the required prop to the combobox FieldLabel
  • Loading branch information
gu-stav authored Sep 16, 2022
2 parents b00351a + 42add10 commit 084ba39
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/strapi-design-system/src/Combobox/Combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@ import { KeyboardKeys } from '../helpers/keyboardKeys';
import { VisuallyHidden } from '../VisuallyHidden';

export const Combobox = ({
children: nodes,
clearLabel,
creatable,
createMessage,
disabled,
hint,
error,
hasMoreItems,
hint,
label,
value,
onChange,
placeholder,
creatable,
labelAction,
loading,
loadingMessage,
noOptionsMessage,
onChange,
onClear,
onCreateOption,
onInputChange,
onLoadMore,
noOptionsMessage,
hasMoreItems,
children: nodes,
onClear,
placeholder,
required,
value,
...props
}) => {
const getInputValueFromNodes = () =>
Expand Down Expand Up @@ -250,7 +252,11 @@ export const Combobox = ({
{value}
</VisuallyHidden>
<Stack spacing={label || hint || error ? 1 : 0}>
{label && <FieldLabel id={labelId}>{label}</FieldLabel>}
{label && (
<FieldLabel action={labelAction} required={required} id={labelId}>
{label}
</FieldLabel>
)}
<MainRow ref={containerRef} $disabled={disabled} hasError={error}>
<InputContainer wrap="wrap">
{!inputValue && value && (
Expand Down Expand Up @@ -396,6 +402,7 @@ Combobox.propTypes = {
hasMoreItems: PropTypes.bool,
hint: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
label: PropTypes.string,
labelAction: PropTypes.element,
loading: PropTypes.bool,
loadingMessage: PropTypes.string,
noOptionsMessage: PropTypes.func,
Expand Down

0 comments on commit 084ba39

Please sign in to comment.