# gpui_web: Simplify keyboard focus model \(\#63989\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/6ad3c7f278e513875e0bbde5ee935f6c9a342b9c)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 6ad3c7f278e513875e0bbde5ee935f6c9a342b9c

Requested commit: 6ad3c7f278e513875e0bbde5ee935f6c9a342b9c

Commit: 6ad3c7f278e513875e0bbde5ee935f6c9a342b9c

Tree: aeaab8e6b82ab7dfbc80a6386cd86b8d7ab65d5e

Author: Cameron Mcloughlin

Committer: GitHub

## Message

```
gpui_web: Simplify keyboard focus model (#63989)

Simplifies the mobile web virtual keyboard implementation in the
following ways:
- assumes that GPUI web apps will set
`interactive-widget=resizes-visual`. This means that GPUI's window will
not change viewport size when the keyboard appears
- Exposes `Window::fully_visible_bounds`, which returns a rectangle
which is fully visible (pixels outside these bounds *may* be visible but
may not be)
- These two changes together mean that keyboard visibility is more
reliably detectable (though not fully), and also makes it easier to have
a stable scroll position when the keyboard is animating in/out
- tweaks the focus model so that:
- transitions into/out of the state "GPUI focus is in a text input, and
that text input is in an editable range" will change keyboard visibility
- manually-dismissed keyboards are preserved by not synchronizing unless
a tap event (or similar, or a programmatic request) on that input
happens
- there is a new `Window::{request,dismiss}_virtual_keyboard()` method
that allows programmatically controlling keyboard visibility (without
interacting with GPUI focus). This allows for patterns like "pressing
button A focuses text field B, *and opens the keyboard*

This PR also fixes a bug in non-touch web that caused text fields to
lose IME mirror focus when they entered non-editable regions, which
could prevent keyboard input from being detected by GPUI properly.

---

Release Notes:

- N/A or Added/Fixed/Improved ...
```

## Parents

- [290cbcb9cb6a5dcbe0060431a126ad19e743f2f4](https://git.cafe/gitcafe/zed/commit/290cbcb9cb6a5dcbe0060431a126ad19e743f2f4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/6ad3c7f278e513875e0bbde5ee935f6c9a342b9c?format=markdown)
