SelectControl: fix display of multiple selections without inline tags. (https://github.com/woocommerce/woocommerce-admin/pull/6862)
* SelectControl: fix display of multiple selections without inline tags. * Add changelog entries.
This commit is contained in:
parent
ffaadf9190
commit
9724b5d9d9
|
@ -1,5 +1,6 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- SelectControl: fix display of multiple selections without inline tags. #6862
|
||||||
- Add new (experimental) list, and add depreciation notice for the current list. #6787
|
- Add new (experimental) list, and add depreciation notice for the current list. #6787
|
||||||
- Force `<SearchListItem>` form elements id to be unique. #6871
|
- Force `<SearchListItem>` form elements id to be unique. #6871
|
||||||
- Add `controlId` and `name` props to `<SearchListItem>`. #6871
|
- Add `controlId` and `name` props to `<SearchListItem>`. #6871
|
||||||
|
|
|
@ -50,10 +50,10 @@ export class SelectControl extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
reset( selected = this.getSelected() ) {
|
reset( selected = this.getSelected() ) {
|
||||||
const { inlineTags } = this.props;
|
const { multiple } = this.props;
|
||||||
const newState = { ...initialState };
|
const newState = { ...initialState };
|
||||||
// Reset to the option label if not using tags.
|
// Reset to the option label if single selection.
|
||||||
if ( ! inlineTags && selected.length && selected[ 0 ].label ) {
|
if ( ! multiple && selected.length && selected[ 0 ].label ) {
|
||||||
newState.query = selected[ 0 ].label;
|
newState.query = selected[ 0 ].label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ export class SelectControl extends Component {
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
hasTags() {
|
hasMultiple() {
|
||||||
const { inlineTags, selected } = this.props;
|
const { multiple, selected } = this.props;
|
||||||
|
|
||||||
if ( ! inlineTags ) {
|
if ( ! multiple ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ export class SelectControl extends Component {
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isExpanded, isFocused, selectedIndex } = this.state;
|
const { isExpanded, isFocused, selectedIndex } = this.state;
|
||||||
|
|
||||||
const hasTags = this.hasTags();
|
const hasMultiple = this.hasMultiple();
|
||||||
const { key: selectedKey = '' } = options[ selectedIndex ] || {};
|
const { key: selectedKey = '' } = options[ selectedIndex ] || {};
|
||||||
const listboxId = isExpanded
|
const listboxId = isExpanded
|
||||||
? `woocommerce-select-control__listbox-${ instanceId }`
|
? `woocommerce-select-control__listbox-${ instanceId }`
|
||||||
|
@ -321,7 +321,7 @@ export class SelectControl extends Component {
|
||||||
'woocommerce-select-control',
|
'woocommerce-select-control',
|
||||||
className,
|
className,
|
||||||
{
|
{
|
||||||
'has-inline-tags': hasTags && inlineTags,
|
'has-inline-tags': hasMultiple && inlineTags,
|
||||||
'is-focused': isFocused,
|
'is-focused': isFocused,
|
||||||
'is-searchable': isSearchable,
|
'is-searchable': isSearchable,
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ export class SelectControl extends Component {
|
||||||
{ ...this.state }
|
{ ...this.state }
|
||||||
activeId={ activeId }
|
activeId={ activeId }
|
||||||
className={ controlClassName }
|
className={ controlClassName }
|
||||||
hasTags={ hasTags }
|
hasTags={ hasMultiple }
|
||||||
isExpanded={ isExpanded }
|
isExpanded={ isExpanded }
|
||||||
listboxId={ listboxId }
|
listboxId={ listboxId }
|
||||||
onSearch={ this.search }
|
onSearch={ this.search }
|
||||||
|
@ -354,7 +354,7 @@ export class SelectControl extends Component {
|
||||||
decrementSelectedIndex={ this.decrementSelectedIndex }
|
decrementSelectedIndex={ this.decrementSelectedIndex }
|
||||||
incrementSelectedIndex={ this.incrementSelectedIndex }
|
incrementSelectedIndex={ this.incrementSelectedIndex }
|
||||||
/>
|
/>
|
||||||
{ ! inlineTags && hasTags && (
|
{ ! inlineTags && hasMultiple && (
|
||||||
<Tags { ...this.props } selected={ this.getSelected() } />
|
<Tags { ...this.props } selected={ this.getSelected() } />
|
||||||
) }
|
) }
|
||||||
{ isExpanded && (
|
{ isExpanded && (
|
||||||
|
|
|
@ -300,4 +300,18 @@ describe( 'SelectControl', () => {
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
it( 'displays multiple selection not inline', async () => {
|
||||||
|
const { getByText } = render(
|
||||||
|
<SelectControl
|
||||||
|
isSearchable
|
||||||
|
options={ options }
|
||||||
|
selected={ [ options[ 1 ] ] }
|
||||||
|
multiple
|
||||||
|
inlineTags={ false }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect( getByText( options[ 1 ].label ) ).toBeInTheDocument();
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -106,6 +106,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
|
||||||
- Fix: Parsing bad JSON string data from user WooCommerce meta. #6819
|
- Fix: Parsing bad JSON string data from user WooCommerce meta. #6819
|
||||||
- Fix: Remove PayPal for India #6828
|
- Fix: Remove PayPal for India #6828
|
||||||
- Fix: Report filters expecting specific ordering. #6847
|
- Fix: Report filters expecting specific ordering. #6847
|
||||||
|
- Fix: Render bug with report comparison mode selections. #6862
|
||||||
- Fix: Throw exception if the data store cannot be loaded when trying to use notes. #6771
|
- Fix: Throw exception if the data store cannot be loaded when trying to use notes. #6771
|
||||||
- Performance: Avoid updating customer info synchronously from the front end. #6765
|
- Performance: Avoid updating customer info synchronously from the front end. #6765
|
||||||
- Tweak: Add settings_section event prop for CES #6762
|
- Tweak: Add settings_section event prop for CES #6762
|
||||||
|
|
Loading…
Reference in New Issue