RFR: 8303478: DatePicker throws uncatchable exception on tab out from garbled text

Michael Strauß mstrauss at openjdk.org
Thu Nov 9 17:52:34 UTC 2023


On Tue, 31 Oct 2023 19:20:48 GMT, brunesto <duke at openjdk.org> wrote:

> The fix prevents the DatePicker from losing focus if the date is not parsable.

modules/javafx.controls/src/main/java/javafx/scene/control/DatePicker.java line 159:

> 157:      * This is to address https://bugs.openjdk.org/browse/JDK-8303478
> 158:      */
> 159:     protected void commitValueOnFocusLost(){

The `protected` modifier makes this method public API, which would most likely require a CSR to be approved. Since there doesn't seem to be a reason why this method should be public, I suggest making it private instead.

modules/javafx.controls/src/main/java/javafx/scene/control/DatePicker.java line 163:

> 161:             commitValue();
> 162:         } catch (DateTimeParseException dtpe) {
> 163:             this.requestFocus();

I'm not sure whether moving focus to the control is a good idea, because this effectively captures focus and forces me to enter a valid date before I can do anything else. Why not just restore the previous value instead?

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1274#discussion_r1378108562
PR Review Comment: https://git.openjdk.org/jfx/pull/1274#discussion_r1378110040


More information about the openjfx-dev mailing list