JDK-8277782 : Regression: DatePicker must commit on focusLost
  • Type: CSR
  • Component: javafx
  • Sub-Component: controls
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: openjfx18
  • Submitted: 2021-11-24
  • Updated: 2022-01-07
  • Resolved: 2021-12-07
Related Reports
CSR :  
Description
Summary
-------

Add the methods *commitValue* and *cancelEdit* to the *DatePicker* class to provide methods which will either commit the value in the DatePicker TextField (set the text as value) or cancel it (set the text based off the value).

Problem
-------

In https://bugs.openjdk.java.net/browse/JDK-8150946, two new methods were added to ComboBox like controls with a TextField (*ComboBox*, *Spinner*): The *commitValue* and *cancelEdit* method. Those two method were simply forgotten for the *DatePicker*, so therefore there is currently no way to commit/cancel a value written in the *DatePicker* TextField.
This also caused a regression, which can be fixed via the proposed api.

Solution
--------

The proposed solution is to add the same two method to the *DatePicker* class as well (which is in fact also a ComboBox like control with a TextField).
Also a lot of new testcases will be added to test this solution.

Specification
-------------

The following two method will be added to the *DatePicker*. They are semantically the same as in *ComboBox* and *Spinner*

    /**
     * If the {@link DatePicker} is {@link #editableProperty() editable}, calling this method will attempt to
     * commit the current text and convert it to a {@link #valueProperty() value}.
     * @since 18
     */
    public final void commitValue() {
        ...
    }

    /**
     * If the {@link DatePicker} is {@link #editableProperty() editable}, calling this method will attempt to
     * replace the editor text with the last committed {@link #valueProperty() value}.
     * @since 18
     */
    public final void cancelEdit() {
       ...
    }
Comments
Moving to Approved.
07-12-2021

Looks good.
07-12-2021

Moving to Provisional; will be willing to vote to Approved after [~kcr] reviews the request and it is Finalized.
07-12-2021

[~mhanl] This is ready to move to _Proposed_. I'll formally review it when I do the code review.
06-12-2021

> the specification section should contain the doc only, not the implementation Exactly what my comment was going to be. See [JDK-8273579](https://bugs.openjdk.java.net/browse/JDK-8273579) for an example. > you might consider to focus the problem section on the api change I think it's good to say that this API change will fix a regression, but I agree that the API change should be the focus.
06-12-2021

just a comment on the formality: the specification section should contain the doc only, not the implementation :) The latter is reviewed in the PR. A tentative suggestion (walking in thin glass here ;) - you might consider to focus the problem section on the api change: we change it to be aligned with other implementations of controls that have an inner textField for input that needs to be handled (commit/cancel) on certain external conditions (like focusLost). From that perspective, fixing the regression is a welcome side-effect but not necessarily the primary driving force.
06-12-2021