Commit 8ad4483e authored by Robert Knight's avatar Robert Knight

Remove "Clear search" button from SearchStatus

The `SearchPanel` component had two buttons that both had the effect of clearing
the search when clicked. We decided that just the panel's "X" button was
sufficient.
parent 25b19bcc
import { Button, CancelIcon } from '@hypothesis/frontend-shared';
import classnames from 'classnames'; import classnames from 'classnames';
import { useMemo } from 'preact/hooks'; import { useMemo } from 'preact/hooks';
...@@ -19,13 +18,11 @@ export default function SearchStatus() { ...@@ -19,13 +18,11 @@ export default function SearchStatus() {
[rootThread, forcedVisibleCount], [rootThread, forcedVisibleCount],
); );
const buttonText = 'Clear search';
return ( return (
<div <div
// This container element needs to be present at all times but // This container element needs to be present at all times but
// should only be visible when there are applied filters // should only be visible when there are applied filters
className={classnames('mb-3 flex items-center justify-center space-x-1', { className={classnames('mb-1 flex items-center justify-center space-x-1', {
'sr-only': !filterQuery, 'sr-only': !filterQuery,
})} })}
data-testid="search-status-container" data-testid="search-status-container"
...@@ -53,19 +50,6 @@ export default function SearchStatus() { ...@@ -53,19 +50,6 @@ export default function SearchStatus() {
</> </>
)} )}
</div> </div>
{filterQuery && (
<Button
onClick={() => store.clearSelection()}
size="sm"
title={buttonText}
variant="primary"
data-testid="clear-button"
>
{/** @TODO: Set `icon` prop in `Button` instead when https://github.com/hypothesis/frontend-shared/issues/675 is fixed */}
{filterQuery && <CancelIcon />}
{buttonText}
</Button>
)}
</div> </div>
); );
} }
...@@ -37,14 +37,6 @@ describe('SearchStatus', () => { ...@@ -37,14 +37,6 @@ describe('SearchStatus', () => {
assert.equal(filterText, text); assert.equal(filterText, text);
} }
function clickClearButton(wrapper) {
const button = wrapper.find('Button[data-testid="clear-button"]');
assert.equal(button.text(), 'Clear search');
assert.isTrue(button.find('CancelIcon').exists());
button.props().onClick();
assert.calledOnce(fakeStore.clearSelection);
}
context('when no search filters are active', () => { context('when no search filters are active', () => {
it('should render hidden but available to screen readers', () => { it('should render hidden but available to screen readers', () => {
const wrapper = createComponent(); const wrapper = createComponent();
...@@ -63,10 +55,6 @@ describe('SearchStatus', () => { ...@@ -63,10 +55,6 @@ describe('SearchStatus', () => {
fakeThreadUtil.countVisible.returns(1); fakeThreadUtil.countVisible.returns(1);
}); });
it('should provide a "Clear search" button that clears the selection', () => {
clickClearButton(createComponent());
});
it('should show the count of matching results', () => { it('should show the count of matching results', () => {
assertFilterText(createComponent(), "Showing 1 result for 'foobar'"); assertFilterText(createComponent(), "Showing 1 result for 'foobar'");
}); });
...@@ -92,9 +80,5 @@ describe('SearchStatus', () => { ...@@ -92,9 +80,5 @@ describe('SearchStatus', () => {
it('should show a separate count for results versus forced visible', () => { it('should show a separate count for results versus forced visible', () => {
assertFilterText(createComponent(), "Showing 2 results for 'foobar'"); assertFilterText(createComponent(), "Showing 2 results for 'foobar'");
}); });
it('should provide a "Clear search" button that clears the selection', () => {
clickClearButton(createComponent());
});
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment