vaadin / vaadin/framework

Initial focus in a date field does not select the text nor does it have a selectAll method

Open
#10,682 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

If you have a DateField and focus it, the date string will not be selected. This also applies to TextInput, but for TextInput there's a selectAll method.

Could you automatically select the text for a focused date field or implement a selectAll method for DateField. If you tabulate out of a date field and tabulate back, the text wil automatically be selected, so why not for the initial focus?

import java.time.LocalDate;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.DateField;
import com.vaadin.ui.UI;

public class ParsableDateFieldTestUI extends UI {

	@Override
	protected void init(VaadinRequest vaadinRequest) {
		DateField dateField = new DateField();
		dateField.setValue(LocalDate.now());
		dateField.focus();
		setContent(dateField);
	}
}

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 with DateField and the provided ParsableDateFieldTestUI entry point, then compare its initial focus behavior with TextInput's selectAll behavior. Confirm the expected behavior for initial focus and focus after tabbing, and consider the issue complete when the date text is selected or DateField exposes equivalent selectAll behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.