Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8277782

Regression: DatePicker must commit on focusLost

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: openjfx18
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source, binary
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      This adds two new new methods similar to the ComboBox class, and fixes a behavioral anomaly in the user interface as a result. There is a small chance that some users could be relying on the existing behavior.
    • Interface Kind:
      Java API
    • Scope:
      JDK

      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() {
         ...
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mhanl Marius Hanl
              Reporter:
              fastegal Jeanette Winzenburg
              Reviewed By:
              Kevin Rushforth
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: