linebender / linebender/druid

Widgets should have opportunity to decline losing focus

Open
#1,664 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

architecture enhancement
Dominant language
Rust
Stars
9.7k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Currently, if the user tabs away from a field or another widget tries to take focus, there is no clear way for the currently focused widget to override the focus loss, without doing hacky things like sending itself a `Command` and taking focus back immediately afterwards. (which is what the textbox does).

This feels bad; there are lots of cases where you want a widget to be able to decline a focus change, such as when its current contents are invalid.

I think this should be fairly easy to manage by adding an additional lifecycle event; I think the pattern I would go with here is the `Cell` trick we use in some of the debug events, where we pass a `Cell` along with the event and then the widget can set this flag if it wants to retain focus.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the focus-change lifecycle and reviewing the existing debug events that use the Cell pattern. Define the lifecycle event's veto behavior for the currently focused widget, then verify that widgets can retain focus without sending a Command to reclaim it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.