vaadin / vaadin/framework

TextField looses focus on .withStatusLabel on FormLayout

Open
#10,356 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

i've had an issue with the input-focus while using the binders .withStatusLabel on a textfield. The following snippet is reproducing the problem. If I focus the (empty) textfield and enter some text the status-label is hidden and the input-field looses focus. If i refocus the input and clear all text the status-label is made visible and the input looses focus again.
If i use a HorizontalLayout instead of a Formlayout the problem doesn't appear, the focus is kept regardless of the status-label.

TextField fieldA = new TextField("Field A");
Label errorA = new Label();
FormLayout form = new FormLayout(fieldA, errorA);
binder.forField(fieldA)
          .asRequired("required")
          .withStatusLabel(errorA)
          .bind(ImageViewerDemoUI::getA, ImageViewerDemoUI::setA);

Vaadin-Version 8.1.6
Demo-Projekt: vaadin-tester.zip

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 reproducing the provided TextField, FormLayout, and Binder.withStatusLabel example on Vaadin 8.1.6, then compare it with the HorizontalLayout variant. The fix is complete when showing or hiding the status label no longer causes the focused input to lose focus.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
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.