bevyengine / bevyengine/bevy

Support more powerful filters in EditableText

Open
#24,894 2 comments 0 reactions 0 assignees View on GitHub
A-UI C-Feature D-Modest S-Needs-Design X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

Having per-character text filtering in EditableText is unable to perform context-aware filters like enforcing special text like decimal numbers, phone numbers, emails, etc.

e.g. To enforce a decimal number you can have only one decimal, and one minus optionally at the start. Allowing a period or minus character in the current EditableTextFilter could allow invalid numeric texts which could be properly filtered out with this new feature.

## What solution would you like?

The EditableTextFilter component could be expanded to support this as well as the per-character filter option.

Or a new component could be added.

maybe something like this, passing the whole text instead of the newest character in the filter fn (untested)
```rust
pub fn new(filter: impl Fn(str) -> bool + Send + Sync + 'static) -> Self {
Self(Some(Arc::new(filter)))
}
```

## What alternative(s) have you considered?

* Adding a custom filter on top of this. Though I assume this would need to roll back invalid character changes and get somewhat complex
* Having a validation message and having the user correct their input

## Additional context

Contributor guide

Open the contributing guide

Research direction

Start by locating the EditableText and EditableTextFilter entry points and reading how the current per-character filter is applied. Compare the requested whole-text filtering behavior with the existing filter option and determine how decimal, phone-number, or email constraints should be represented; done means context-aware filtering works without removing the existing per-character option.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.