Skip to content

window(core): disable text input focus and cursor when popup closes#11005

Draft
Murmele wants to merge 3 commits intoslint-ui:masterfrom
Murmele:mm/android_fix_cursor_popup_close
Draft

window(core): disable text input focus and cursor when popup closes#11005
Murmele wants to merge 3 commits intoslint-ui:masterfrom
Murmele:mm/android_fix_cursor_popup_close

Conversation

@Murmele
Copy link
Contributor

@Murmele Murmele commented Mar 13, 2026

Disable text input focus and cursor state when a popup is closed to ensure a clean UI state. This prevents lingering cursor visibility and input focus issues after popup dismissal.

Fixes #11004

Disable text input focus and cursor state when a popup is closed to ensure a clean UI state. This prevents lingering cursor visibility and input focus issues after popup dismissal.

- Explicitly set text input focus to `false` for the window
- Disable input method for the window adapter when available
- Maintain existing dirty region and redraw logic for popup updates

Fixes slint-ui#11004
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Is it possible to make a test for this?

I'm wondering if this is something that is specific with the popup or has the problem also for any component destruction.

For example:

if condition: LineEdit {}

When condition becomes false when the LineEdit has the focus, is there not the same bug?

I would hope that the general existing focus handing code would take care of this. And maybe that is actually the bug.

@Murmele
Copy link
Contributor Author

Murmele commented Mar 17, 2026

In general the TextInput gets the FocusOut event when it looses focus and therefore the cursor will be hidden (set_cursor_position() will be called with false for the visibility) so here it is fine.

When the popup gets destroyed the TextInput does not receive the FocusOut event and therefore the Cursor was not hidden. Maybe it can be implemented more generic that first the popup takes the focus so all objects loose the focus and then closing it?

I tested your case:

export component MainWindow inherits Window {
    VerticalLayout {
        padding: 20px;
        alignment: space-between;

        property <bool> hide: false;

        Timer {
            running: true;
            interval: 10s;
            triggered => {
                parent.hide = true;
            }
        }

        if !hide: LineEdit {
            edited(text) => {
            }
        }

        Rectangle {}
    }
}

We have the problem here as well. Also the keyboard does not disappear. The FocusOut Event was not triggered

Bildschirmaufzeichnung.vom.2026-03-17.09-28-49.mp4

@Murmele Murmele marked this pull request as draft March 17, 2026 08:31
@ogoffart
Copy link
Member

I see. I wonder what is the cleanest way to fix this issue.
Maybe we could check in unregister_item_tree if the focus item becomes invalid?

@Murmele
Copy link
Contributor Author

Murmele commented Mar 17, 2026

I see. I wonder what is the cleanest way to fix this issue. Maybe we could check in unregister_item_tree if the focus item becomes invalid?

You think about unfocusing all elements? I will try to write a few tests so we catch all cases and don't destroy anything else

@ogoffart
Copy link
Member

In unregister_item_tree, we could check if this removes the currently focused element, and if yes, we should handle that case and disable the IME.

@Murmele
Copy link
Contributor Author

Murmele commented Mar 19, 2026

In unregister_item_tree, we could check if this removes the currently focused element, and if yes, we should handle that case and disable the IME.

I would prefer that the items FocusOut is called so if there is anything else to cleanup can be done there as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: Cursor gets not hidden when leaving Popup

2 participants