Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/ui-select/src/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ class Select extends Component<SelectProps> {
onBlur,
onInputChange,
onRequestHideOptions,
layout,
...rest
} = this.props

Expand Down Expand Up @@ -745,6 +746,7 @@ class Select extends Component<SelectProps> {
: interaction,
isRequired,
shouldNotWrap,
layout,
display: isInline ? 'inline-block' : 'block',
renderBeforeInput: this.handleRenderBeforeInput(),
// On iOS VoiceOver, if there is a custom element instead of the changing up and down arrow button
Expand Down
14 changes: 12 additions & 2 deletions packages/ui-select/src/Select/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ type PropsFromTextInput = {
* when available space is exceeded.
*/
shouldNotWrap?: boolean

/**
* In `stacked` mode the input is below the label.
*
* In `inline` mode the input is to the right/left (depending on text direction) of the label,
* and the layout will look like `stacked` for small screens.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better text suggestion (use the same for SimpleSelect too):

In stacked mode the input is below the label.
In inline mode the input is to the right/left (depending on text direction) of the label, and the layout will look like stacked for small screens

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matyasf thanks, I added this to both.

layout?: 'stacked' | 'inline'
}

// These props are directly passed to Popover
Expand Down Expand Up @@ -328,7 +336,8 @@ const propTypes: PropValidators<PropKeys> = {
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
children: ChildrenPropTypes.oneOf([Group, Option]),
shouldNotWrap: PropTypes.bool,
scrollToHighlightedOption: PropTypes.bool
scrollToHighlightedOption: PropTypes.bool,
layout: PropTypes.oneOf(['stacked', 'inline'])
}

const allowedProps: AllowedPropKeys = [
Expand Down Expand Up @@ -365,7 +374,8 @@ const allowedProps: AllowedPropKeys = [
'renderAfterInput',
'children',
'shouldNotWrap',
'scrollToHighlightedOption'
'scrollToHighlightedOption',
'layout'
]

export type { SelectProps, SelectOwnProps, SelectStyle }
Expand Down
2 changes: 2 additions & 0 deletions packages/ui-simple-select/src/SimpleSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
onShowOptions,
onHideOptions,
children,
layout,
...rest
} = this.props

Expand Down Expand Up @@ -493,6 +494,7 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
onRequestHighlightOption={this.handleHighlightOption}
onRequestSelectOption={this.handleSelectOption}
isOptionContentAppliedToInput={this.props.isOptionContentAppliedToInput}
layout={layout}
{...passthroughProps(rest)}
>
{this.renderChildren()}
Expand Down
15 changes: 13 additions & 2 deletions packages/ui-simple-select/src/SimpleSelect/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ type PropsPassedToSelect = {
* If the selected `SimpleSelect.Option`'s `renderAfterLabel` value is empty, default arrow icon will be rendered.
*/
isOptionContentAppliedToInput?: boolean

/**
* In `stacked` mode the input is below the label.
*
* In `inline` mode the input is to the right/left (depending on text direction) of the label,
* and the layout will look like `stacked` for small screens.
*/
layout?: 'stacked' | 'inline'
}

type PropKeys = keyof SimpleSelectOwnProps
Expand All @@ -248,6 +256,7 @@ type SimpleSelectProps = PickPropsWithExceptions<
| 'onRequestSelectOption'
| 'inputValue'
| 'isShowingOptions'
| 'layout'
> &
SimpleSelectOwnProps &
OtherHTMLAttributes<
Expand Down Expand Up @@ -294,7 +303,8 @@ const propTypes: PropValidators<PropKeys> = {
renderBeforeInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
renderAfterInput: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
children: ChildrenPropTypes.oneOf([Group, Option]),
isOptionContentAppliedToInput: PropTypes.bool
isOptionContentAppliedToInput: PropTypes.bool,
layout: PropTypes.oneOf(['stacked', 'inline'])
}

const allowedProps: AllowedPropKeys = [
Expand Down Expand Up @@ -326,7 +336,8 @@ const allowedProps: AllowedPropKeys = [
'renderEmptyOption',
'renderBeforeInput',
'renderAfterInput',
'children'
'children',
'layout'
]

export type { SimpleSelectProps, SimpleSelectState }
Expand Down
Loading