Skip to content

Commit 6313de2

Browse files
pedrosousanevikashah
authored andcommitted
[Ruleset Engine] FieldCatalog: Clear input on Esc key (#24738)
1 parent 5f200b1 commit 6313de2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/FieldCatalog.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { useEffect, useState, type ChangeEvent } from "react";
1+
import {
2+
useEffect,
3+
useState,
4+
type ChangeEvent,
5+
type KeyboardEvent,
6+
} from "react";
27
import FieldBadges from "./fields/FieldBadges";
38
import Markdown from "react-markdown";
49
import type { CollectionEntry } from "astro:content";
@@ -95,6 +100,11 @@ const FieldCatalog = ({ fields }: { fields: Fields }) => {
95100
placeholder="Search fields"
96101
value={filters.search}
97102
onChange={(e) => setFilters({ ...filters, search: e.target.value })}
103+
onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {
104+
if (e.key === "Escape") {
105+
setFilters({ ...filters, search: "" });
106+
}
107+
}}
98108
/>
99109

100110
<div className="mb-8! hidden md:block">

0 commit comments

Comments
 (0)