Skip to content

Commit

Permalink
fix(FilterableMultiSelect): extend input outline to trigger button ar…
Browse files Browse the repository at this point in the history
…ea (#7722)

* refactor(multi-select): avoid duplicate selector

* fix(FilterableMultiSelect): extend input outline to trigger button area

* chore: update snapshots
  • Loading branch information
emyarod committed Feb 5, 2021
1 parent 79db553 commit c111af1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/components/src/components/multi-select/_multi-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,29 @@
color: $text-01;
}

.#{$prefix}--multi-select--filterable {
transition: outline-color $duration--fast-01 motion(standard, productive);
}

.#{$prefix}--multi-select--filterable.#{$prefix}--combo-box
.#{$prefix}--text-input {
background-clip: padding-box;
border: rem(2px) solid transparent;
outline: none;
}

.#{$prefix}--multi-select--filterable--input-focused {
@include focus-outline('outline');
}

.#{$prefix}--multi-select--filterable.#{$prefix}--list-box--disabled:hover
.#{$prefix}--text-input {
background-color: $field-01;
}

.#{$prefix}--multi-select--filterable {
.#{$prefix}--multi-select--filterable
.#{$prefix}--list-box__selection--multi {
margin: 0 0 0 $spacing-05;
}
margin: 0 0 0 $spacing-05;
}

.#{$prefix}--multi-select--filterable.#{$prefix}--multi-select--inline,
Expand Down
13 changes: 13 additions & 0 deletions packages/react/src/components/MultiSelect/FilterableMultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default class FilterableMultiSelect extends React.Component {
isOpen: props.open,
inputValue: '',
topItems: [],
inputFocused: false,
};
}

Expand Down Expand Up @@ -273,6 +274,14 @@ export default class FilterableMultiSelect extends React.Component {
this.inputNode && this.inputNode.focus && this.inputNode.focus();
};

handleInputFocus = (_) => {
this.setState({ inputFocused: true });
};

handleInputBlur = (_) => {
this.setState({ inputFocused: false });
};

render() {
const { highlightedIndex, isOpen, inputValue } = this.state;
const {
Expand Down Expand Up @@ -385,6 +394,8 @@ export default class FilterableMultiSelect extends React.Component {
[`${prefix}--multi-select--inline`]: inline,
[`${prefix}--multi-select--selected`]:
selectedItem.length > 0,
[`${prefix}--multi-select--filterable--input-focused`]: this
.state.inputFocused,
}
);
const buttonProps = {
Expand Down Expand Up @@ -426,6 +437,8 @@ export default class FilterableMultiSelect extends React.Component {
{...getInputProps({
disabled,
placeholder,
onFocus: this.handleInputFocus,
onBlur: this.handleInputBlur,
onKeyDown: this.handleOnInputKeyDown,
})}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ exports[`MultiSelect.Filterable should render 1`] = `
id="test-filterable-multiselect-input"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
placeholder="Placeholder..."
value=""
Expand Down

0 comments on commit c111af1

Please sign in to comment.