Skip to content

Commit eb6c0ce

Browse files
committed
fix: blur search bar on pressing enter
to make keyboard disappear
1 parent 505457e commit eb6c0ce

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

widgets/workflow_search.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ def render_search_filters(
7070
)
7171

7272

73-
def render_search_bar(key: str = "search_query", value: str = "") -> str:
73+
def render_search_bar(
74+
key: str = "search_query", value: str = "", id: str | None = None
75+
) -> str:
76+
id = id or f"--search_bar:{key}"
77+
7478
with (
7579
gui.styled(
7680
r"""
@@ -109,10 +113,19 @@ def render_search_bar(key: str = "search_query", value: str = "") -> str:
109113
style=dict(resize="none", paddingLeft="2.7rem", paddingRight="2.7rem"),
110114
key=key,
111115
value=value,
116+
id=id,
112117
)
113118

114119
# add a hidden submit button to allow form submission on pressing Enter
115-
gui.html('<input type="submit" hidden />')
120+
gui.button(
121+
"",
122+
className="m-0 p-0",
123+
hidden=True,
124+
onClick=f"""
125+
event.preventDefault();
126+
document.getElementById("{id}").blur();
127+
""",
128+
)
116129

117130
if search_query and gui.button(
118131
icons.cancel, type="link", className="clear_button"

0 commit comments

Comments
 (0)