FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
124 stars 23 forks source link

TextField with Mask: All Characters Deleted when Editing #1705

Closed alexsanderp closed 10 months ago

alexsanderp commented 1 year ago

Has your issue been reported?

Current Behavior

I'm facing a problem that has left me a bit puzzled and I would greatly appreciate your help in resolving it. I'm working on a Flutter project and using TextField widgets with masks. The issue I'm encountering is that when I set an initial value for the field and try to edit it, all the characters get deleted, which is not the expected behavior.

Expected Behavior

Being able to edit text in a textfield with an initial value that has a mask.

Steps to Reproduce

  1. Create a masked textfield (AAAAAA or ##)
  2. Fill this textfield using initial value or fill it through an action
  3. Try editing the textfield data

Reproducible from Blank

Bug Report Code (Required)

ITFTlMmAx4VOodtb+KXtKcF4r2QXI0McX5Ir1utsewgjGKL1Bux/O87sXFpoXu2naVNcJFSLmngd/8LUhvDhK/QnAyqcQY861rpcFg3ke2iuMLawBc3pYHB5NJ5mIX6m57SRgiR+KtJpL1okwDvzIvK8VgXDFOu/Zwh9f6PHaOI=

Context

It affects the user experience as they have to rewrite everything every time they need to edit something

Visual documentation

Gravação de tela de 25-10-2023 18:54:37.webm

Additional Info

Doesn't happen with unmasked textfields

Environment

- FlutterFlow version: v3.1
- Platform: Web
- Browser name and version: Chrome 116.0.5845.96
- Operating system and version affected: Linux Ubuntu 22.04
github-actions[bot] commented 12 months ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.

alexsanderp commented 11 months ago

Any update? @agreaves @hariprasadms

agreaves commented 10 months ago

Hi @alexsanderp, unfortunately this is how the TextField Mask in Flutter works. If you the value currently entered in the TextField does not match the mask, it removes the existing text. The fix is to make sure that the mask you use actually matches the text that is entered in the text field.

In general, I'd recommend using form validation or specifying the Keyboard type (e.g. only numbers, email keyboard, etc).

alexsanderp commented 7 months ago

I believe that might not be the issue. When I have a number mask and try to edit a field by adding one more number at the end, the entire text gets deleted...