Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataViews: Remove second reset filter button in filter dialog #58960

Merged
merged 1 commit into from
Feb 13, 2024
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
39 changes: 0 additions & 39 deletions packages/dataviews/src/filter-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import classnames from 'classnames';
*/
import {
Dropdown,
Button,
__experimentalVStack as VStack,
__experimentalHStack as HStack,
FlexItem,
Expand Down Expand Up @@ -133,40 +132,6 @@ function OperatorSelector( { filter, view, onChangeView } ) {
);
}

function ResetFilter( { filter, view, onChangeView, addFilterRef } ) {
const isDisabled =
filter.isPrimary &&
view.filters.find( ( _filter ) => _filter.field === filter.field )
?.value === undefined;
return (
<div className="dataviews-filter-summary__reset">
<Button
disabled={ isDisabled }
__experimentalIsFocusable
size="compact"
variant="tertiary"
style={ { justifyContent: 'center', width: '100%' } }
onClick={ () => {
onChangeView( {
...view,
page: 1,
filters: view.filters.filter(
( _filter ) => _filter.field !== filter.field
),
} );
// If the filter is not primary and can be removed, it will be added
// back to the available filters from `Add filter` component.
if ( ! filter.isPrimary ) {
addFilterRef.current?.focus();
}
} }
>
{ filter.isPrimary ? __( 'Reset' ) : __( 'Remove' ) }
</Button>
</div>
);
}

export default function FilterSummary( {
addFilterRef,
openedFilter,
Expand Down Expand Up @@ -269,10 +234,6 @@ export default function FilterSummary( {
<VStack spacing={ 0 } justify="flex-start">
<OperatorSelector { ...commonProps } />
<SearchWidget { ...commonProps } />
<ResetFilter
{ ...commonProps }
addFilterRef={ addFilterRef }
/>
</VStack>
);
} }
Expand Down
5 changes: 0 additions & 5 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,6 @@
}
}

.dataviews-filter-summary__reset {
padding: $grid-unit-05;
border-top: 1px solid $gray-200;
}

.dataviews-filter-summary__chip-container {
position: relative;
white-space: pre-wrap;
Expand Down
Loading