diff --git a/.changeset/clear-filter-button.md b/.changeset/clear-filter-button.md new file mode 100644 index 00000000000..07fade0e312 --- /dev/null +++ b/.changeset/clear-filter-button.md @@ -0,0 +1,5 @@ +--- +'@tanstack/query-devtools': minor +--- + +Add clear button to filter input for improved UX. The button appears when the filter has text and clears the filter when clicked, automatically refocusing the input field. Works for both queries and mutations views. diff --git a/packages/query-devtools/src/Devtools.tsx b/packages/query-devtools/src/Devtools.tsx index cceec7a3de5..8790237234e 100644 --- a/packages/query-devtools/src/Devtools.tsx +++ b/packages/query-devtools/src/Devtools.tsx @@ -676,6 +676,7 @@ export const ContentView: Component = (props) => { setupQueryCacheSubscription() setupMutationCacheSubscription() let containerRef!: HTMLDivElement + let filterInputRef!: HTMLInputElement const theme = useTheme() const css = useQueryDevtoolsContext().shadowDOMTarget ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget }) @@ -907,6 +908,7 @@ export const ContentView: Component = (props) => { > = (props) => { : props.localStore.mutationFilter || '' } /> + + +
svg { + width: ${size[3]}; + height: ${size[3]}; + } + + &:hover { + color: ${t(colors.gray[700], colors.gray[200])}; + } + + &:focus-visible { + outline: 2px solid ${colors.blue[800]}; + outline-offset: 2px; + border-radius: ${border.radius.xs}; + } + `, filterSelect: css` padding: ${tokens.size[0.5]} ${tokens.size[2]}; border-radius: ${tokens.border.radius.sm};