Skip to content

Flutter should expose text editing shortcut logic for reuse #97830

@justinmc

Description

@justinmc

Flutter has a ton of logic for handling keyboard shortcuts in the framework, mapping them in default_text_editing_shortcuts.dart and actually handling them privately in editable_text.dart. We should make this logic reusable by developers writing their own text editors.

Why?

Previously, this logic was exposed in a class called TextEditingActionTarget, but that was removed in #90684. It was brought up in the comments after merge that this change had broken two major text editing projects.

Besides being impractical for developers to reimplement all of this logic on their own, doing so would quickly get out of sync with Flutter's behavior and cause strange discrepancies in text editing behavior between simple TextFields and the custom text editors.

How?

The shortcuts and their behavior is already overridable by using Shortcuts and Actions widgets, but the problem is applying them to something other than an EditableText. This was possible by mixing in TextEditingActionTarget, but it was brought up in the comments that a composable solution may be preferred instead.

We should flesh out this idea and then expose it publicly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: contributor-productivityTeam-specific productivity, code health, technical debt.c: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions