diff --git a/src/components/Searchbar.tsx b/src/components/Searchbar.tsx index f1f6adbbfd..011d45815e 100644 --- a/src/components/Searchbar.tsx +++ b/src/components/Searchbar.tsx @@ -300,10 +300,8 @@ const Searchbar = ({ {loading ? ( ) : ( - // Clear icon should be always rendered within Searchbar – it's transparent, - // without touch events, when there is no value. It's done to avoid issues - // with the abruptly stopping ripple effect and changing bar width on web, - // when clearing the value. + // Keep the clear button mounted so its ripple can finish and clearing + // the value does not cause a layout shift on web. ( diff --git a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap index c13c51a6cd..16d666f59b 100644 --- a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap +++ b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap @@ -331,46 +331,16 @@ exports[`Appbar does not pass any additional props to Searchbar 1`] = ` } > { + const { rerender } = await render(); + + expect(screen.queryByRole('button', { name: 'clear' })).toBeNull(); + expect( + screen.getByLabelText('clear', { includeHiddenElements: true }) + ).toHaveProp('aria-hidden', true); + + await rerender(); + + expect(screen.getByRole('button', { name: 'clear' })).toBeEnabled(); + + await rerender(); + + expect(screen.queryByRole('button', { name: 'clear' })).toBeNull(); +}); + it('defines onClearIconPress action and checks if it is called when close button is pressed', async () => { const onClearIconPressMock = jest.fn(); await render( diff --git a/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap b/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap index a8d788e309..1e759ab517 100644 --- a/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap @@ -716,46 +716,16 @@ exports[`renders searchbar in "view" mode 1`] = ` } >