vaadin / vaadin/framework

Add support for TextField auto-trim

Open
#7,559 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement workaround
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Originally by mvysny2


A setter e.g. TextField.setAutoTrim(true) will be very helpful.

Recently I encountered a bug in the user registration form, where users inputted their username as "foo "; the TextField was directly bound to a JPA bean and that trailing space made it into the database. The login dialog correctly trimmed the username field and as you can imagine, the user couldn't log in :-)

I know I can probably do this with a proper converter, yet a setter would be more helpful: it is way shorter and can be set from design html file.

Thank you :)


Imported from https://dev.vaadin.com/ issue #19680

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 locating the TextField component and its existing value, binding, and converter behavior. Review how component properties can be configured from a design HTML file. Done means TextField.setAutoTrim(true) is available and trailing spaces are removed before the value reaches the bound JPA bean, with the behavior covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.