File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed
app/code/Magento/Ui/view/base/web/js/form/element
dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,11 @@ define([
8787 initConfig : function ( ) {
8888 this . _super ( ) ;
8989
90+ // Adopt picker format if provided under options in UI XML
91+ if ( this . options && this . options . pickerDateTimeFormat ) {
92+ this . pickerDateTimeFormat = this . options . pickerDateTimeFormat ;
93+ }
94+
9095 if ( ! this . options . dateFormat ) {
9196 this . options . dateFormat = this . pickerDefaultDateFormat ;
9297 }
@@ -95,6 +100,11 @@ define([
95100 this . options . timeFormat = this . pickerDefaultTimeFormat ;
96101 }
97102
103+ // If date-only and a picker format is explicitly configured, prefer it for calendar display format
104+ if ( ! this . options . showsTime && this . pickerDateTimeFormat ) {
105+ this . options . dateFormat = this . pickerDateTimeFormat ;
106+ }
107+
98108 this . prepareDateTimeFormats ( ) ;
99109
100110 return this ;
Original file line number Diff line number Diff line change 11/**
2- * Copyright © Magento, Inc. All rights reserved.
3- * See COPYING.txt for license details .
2+ * Copyright 2015 Adobe
3+ * All Rights Reserved .
44 */
55
66define ( [
@@ -82,5 +82,30 @@ define([
8282 model . value ( '2:43 am' ) ;
8383 expect ( model . getPreview ( ) ) . toBe ( '02:43:00' ) ;
8484 } ) ;
85+
86+ it ( 'Prefers pickerDateTimeFormat for date-only display format' , function ( ) {
87+ // simulate UI XML providing pickerDateTimeFormat while showsTime is false
88+ model . options . showsTime = false ;
89+ model . options . pickerDateTimeFormat = 'MM/dd/y' ;
90+
91+ // Re-init to adopt option and set options.dateFormat accordingly
92+ model . initConfig ( ) ;
93+
94+ expect ( model . options . dateFormat ) . toBe ( 'MM/dd/y' ) ;
95+ } ) ;
96+
97+ it ( 'Displays value using pickerDateTimeFormat when date-only' , function ( ) {
98+ model . options . showsTime = false ;
99+ // Ensure consistent IO formats for this test case
100+ model . outputDateFormat = 'MM/dd/y' ;
101+ model . inputDateFormat = 'MM/dd/y' ;
102+ model . pickerDateTimeFormat = 'MM/dd/y' ;
103+
104+ // Make sure formats are prepared
105+ model . prepareDateTimeFormats ( ) ;
106+
107+ model . value ( '21-11-2025' ) ;
108+ expect ( model . getPreview ( ) ) . toBe ( '21-11-2025' ) ;
109+ } ) ;
85110 } ) ;
86111} ) ;
You can’t perform that action at this time.
0 commit comments