Skip to content

Commit

Permalink
Update filter control position
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskoster committed Feb 21, 2024
1 parent a04a8e9 commit c18a42b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
36 changes: 18 additions & 18 deletions packages/dataviews/src/dataviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,30 @@ export default function DataViews( {
<div className="dataviews-wrapper">
<VStack spacing={ 3 } justify="flex-start">
<HStack
alignment="flex-start"
alignment="top"
justify="start"
className="dataviews-filters__view-actions"
>
{ search && (
<Search
label={ searchLabel }
<HStack
justify="start"
className="dataviews-filters__container"
wrap
>
{ search && (
<Search
label={ searchLabel }
view={ view }
onChangeView={ onChangeView }
/>
) }
<Filters
fields={ _fields }
view={ view }
onChangeView={ onChangeView }
openedFilter={ openedFilter }
setOpenedFilter={ setOpenedFilter }
/>
) }
</HStack>
{ [ LAYOUT_TABLE, LAYOUT_GRID ].includes( view.type ) && (
<BulkActions
actions={ actions }
Expand All @@ -106,19 +119,6 @@ export default function DataViews( {
supportedLayouts={ supportedLayouts }
/>
</HStack>
<HStack
justify="start"
className="dataviews-filters__container"
wrap
>
<Filters
fields={ _fields }
view={ view }
onChangeView={ onChangeView }
openedFilter={ openedFilter }
setOpenedFilter={ setOpenedFilter }
/>
</HStack>
<ViewComponent
fields={ _fields }
view={ view }
Expand Down
7 changes: 6 additions & 1 deletion packages/dataviews/src/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AddFilter from './add-filter';
import ResetFilters from './reset-filters';
import { sanitizeOperators } from './utils';
import { ENUMERATION_TYPE, OPERATOR_IN, OPERATOR_NOT_IN } from './constants';
import { __experimentalHStack as HStack } from '@wordpress/components';

const Filters = memo( function Filters( {
fields,
Expand Down Expand Up @@ -108,7 +109,11 @@ const Filters = memo( function Filters( {
);
}

return filterComponents;
return (
<HStack justify="flex-start" style={ { width: 'fit-content' } } wrap>
{ filterComponents }
</HStack>
);
} );

export default Filters;
8 changes: 1 addition & 7 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@
.dataviews-filters__view-actions {
padding: $grid-unit-15 $grid-unit-40 0;
.components-search-control {
flex-grow: 1;

.components-base-control__field {
max-width: 240px;
}
}
}

.dataviews-filters__container {
padding: 0 $grid-unit-40;
}

.dataviews-filters__view-actions.components-h-stack {
align-items: center;
padding-right: $grid-unit-40;
}

.dataviews-filters-button {
Expand Down

0 comments on commit c18a42b

Please sign in to comment.