From f4c2140258afb5ffe6cae4d993962a6976a23125 Mon Sep 17 00:00:00 2001 From: Paul Sealock Date: Wed, 21 Nov 2018 11:53:57 +1300 Subject: [PATCH] Update uses of Gutenberg popover for content sizing --- .../components/src/filters/date/content.js | 4 +--- .../packages/components/src/filters/date/index.js | 9 --------- .../components/src/filters/filter/index.js | 1 + .../components/src/search/autocomplete.js | 7 +++++-- .../packages/components/src/search/index.js | 15 ++++++++++++--- .../packages/components/src/search/style.scss | 4 ++++ 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/plugins/woocommerce-admin/packages/components/src/filters/date/content.js b/plugins/woocommerce-admin/packages/components/src/filters/date/content.js index 410c901928f..a0534e517ba 100644 --- a/plugins/woocommerce-admin/packages/components/src/filters/date/content.js +++ b/plugins/woocommerce-admin/packages/components/src/filters/date/content.js @@ -24,7 +24,7 @@ class DatePickerContent extends Component { this.onTabSelect = this.onTabSelect.bind( this ); } onTabSelect( tab ) { - const { onUpdate, period, refreshDropdown } = this.props; + const { onUpdate, period } = this.props; /** * If the period is `custom` and the user switches tabs to view the presets, @@ -34,8 +34,6 @@ class DatePickerContent extends Component { if ( 'period' === tab && 'custom' === period ) { onUpdate( { period: 'today' } ); } - - refreshDropdown(); } render() { diff --git a/plugins/woocommerce-admin/packages/components/src/filters/date/index.js b/plugins/woocommerce-admin/packages/components/src/filters/date/index.js index 1260dbbbd57..4d3806430ba 100644 --- a/plugins/woocommerce-admin/packages/components/src/filters/date/index.js +++ b/plugins/woocommerce-admin/packages/components/src/filters/date/index.js @@ -35,14 +35,6 @@ class DatePicker extends Component { this.onSelect = this.onSelect.bind( this ); this.isValidSelection = this.isValidSelection.bind( this ); this.resetCustomValues = this.resetCustomValues.bind( this ); - this.refreshDropdown = this.refreshDropdown.bind( this ); - } - - refreshDropdown() { - setTimeout( () => { - const dropdown = this.dropdownRef.current; - dropdown.refresh && dropdown.refresh(); - } ); } getResetState() { @@ -156,7 +148,6 @@ class DatePicker extends Component { afterError={ afterError } beforeError={ beforeError } shortDateFormat={ shortDateFormat } - refreshDropdown={ this.refreshDropdown } /> ) } /> diff --git a/plugins/woocommerce-admin/packages/components/src/filters/filter/index.js b/plugins/woocommerce-admin/packages/components/src/filters/filter/index.js index ee6c1cd5a58..c455173f44c 100644 --- a/plugins/woocommerce-admin/packages/components/src/filters/filter/index.js +++ b/plugins/woocommerce-admin/packages/components/src/filters/filter/index.js @@ -143,6 +143,7 @@ class FilterPicker extends Component { selected={ selectedTag ? [ selectedTag ] : [] } onChange={ partial( this.onTagChange, filter, onClose ) } inlineTags + staticResults /> ); } diff --git a/plugins/woocommerce-admin/packages/components/src/search/autocomplete.js b/plugins/woocommerce-admin/packages/components/src/search/autocomplete.js index ed6da5159e1..01dc348c60c 100644 --- a/plugins/woocommerce-admin/packages/components/src/search/autocomplete.js +++ b/plugins/woocommerce-admin/packages/components/src/search/autocomplete.js @@ -260,7 +260,7 @@ export class Autocomplete extends Component { } render() { - const { children, instanceId, completer: { className = '' } } = this.props; + const { children, instanceId, completer: { className = '' }, staticResults } = this.props; const { selectedIndex, filteredOptions, query } = this.state; const { key: selectedKey = '' } = filteredOptions[ selectedIndex ] || {}; const isExpanded = filteredOptions.length > 0 && !! query; @@ -268,11 +268,14 @@ export class Autocomplete extends Component { const activeId = isExpanded ? `woocommerce-search__autocomplete-${ instanceId }-${ selectedKey }` : null; + const resultsClasses = classnames( 'woocommerce-search__autocomplete-results', { + 'is-static-results': staticResults, + } ); return (
{ children( { isExpanded, listBoxId, activeId, onChange: this.search } ) } { isExpanded && ( -
+
{ isExpanded && map( filteredOptions, ( option, index ) => (