From 41c4b76a05d5929b8dd4b9fa5d67299e3c06fdbc Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Sun, 11 Jan 2026 15:11:19 +0800 Subject: [PATCH] Fix text input focus loss in searchbar/textfield Text input components were losing focus every frame because they failed to register with the field tracking system. The tracking system clears ctx->focused_edit at frame end for unregistered buffers. --- src/input.c | 3 +++ src/searchbar.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index 6edebc8..c0aeba2 100644 --- a/src/input.c +++ b/src/input.c @@ -857,6 +857,9 @@ iui_textfield_result iui_textfield_with_selection( if (!ctx->current_window || !buffer || !state || size == 0) return result; + /* Register this text field for per-frame tracking */ + iui_register_textfield(ctx, buffer); + /* Default options if NULL */ iui_textfield_options opts = {0}; if (options) diff --git a/src/searchbar.c b/src/searchbar.c index a4d9869..e26cfdf 100644 --- a/src/searchbar.c +++ b/src/searchbar.c @@ -29,6 +29,9 @@ iui_search_bar_result iui_search_bar_ex(iui_context *ctx, if (!ctx || !ctx->current_window || !buffer || !cursor || size == 0) return result; + /* Register this text field for per-frame tracking */ + iui_register_textfield(ctx, buffer); + /* Default icons */ const char *lead_icon = leading_icon ? leading_icon : "search"; bool has_text = (buffer[0] != '\0'); @@ -344,8 +347,9 @@ bool iui_search_view_begin(iui_context *ctx, ctx->colors.surface_container_high, ctx->renderer.user); - /* Auto-focus the search field */ + /* Auto-focus the search field and register for tracking */ ctx->focused_edit = search->query; + iui_register_textfield(ctx, search->query); /* Handle text input */ iui_process_text_input(ctx, search->query, sizeof(search->query),