@@ -6,7 +6,9 @@ import resizeCallbacks from '__internal/core/utils/m_resize_callbacks';
66import typeUtils from 'core/utils/type' ;
77import { extend } from 'core/utils/extend' ;
88import visibilityEventsModule from 'common/core/events/visibility_change' ;
9- import { EDITORS_WITHOUT_LABELS } from '__internal/ui/form/m_form.layout_manager.utils' ;
9+ import {
10+ EDITORS_WITHOUT_LABELS ,
11+ } from '__internal/ui/form/m_form.layout_manager.utils' ;
1012import 'generic_light.css!' ;
1113import $ from 'jquery' ;
1214import 'ui/autocomplete' ;
@@ -20,6 +22,10 @@ import 'ui/range_slider';
2022import windowModule from '__internal/core/utils/m_window' ;
2123import Form from 'ui/form' ;
2224import TextEditorBase from 'ui/text_box/ui.text_editor.base.js' ;
25+ import {
26+ TEXTEDITOR_INPUT_CLASS
27+ } from '__internal/ui/text_box/m_text_editor.base' ;
28+
2329
2430import {
2531 FIELD_ITEM_CLASS ,
@@ -57,6 +63,7 @@ import themes from 'ui/themes';
5763import registerKeyHandlerTestHelper from '../../helpers/registerKeyHandlerTestHelper.js' ;
5864import responsiveBoxScreenMock from '../../helpers/responsiveBoxScreenMock.js' ;
5965import { isDefined } from 'core/utils/type.js' ;
66+ import { TABPANEL_CLASS } from '__internal/ui/tab_panel/m_tab_panel' ;
6067
6168const INVALID_CLASS = 'dx-invalid' ;
6269const FORM_GROUP_CONTENT_CLASS = 'dx-form-group-content' ;
@@ -95,9 +102,9 @@ if(device.current().deviceType === 'desktop') {
95102 } ) ;
96103}
97104
98- QUnit . testInActiveWindow ( 'Form\'s inputs saves value on refresh' , function ( assert ) {
105+ QUnit . testInActiveWindow ( 'Form\'s textbox input saves value on refresh (T404958) ' , function ( assert ) {
99106 let screen = 'md' ;
100- const $formContainer = $ ( '#form' ) . dxForm ( {
107+ const $form = $ ( '#form' ) . dxForm ( {
101108 screenByWidth : function ( ) {
102109 return screen ;
103110 } ,
@@ -113,17 +120,48 @@ QUnit.testInActiveWindow('Form\'s inputs saves value on refresh', function(asser
113120 ]
114121 } ) ;
115122
116- $ ( '#form input' )
123+ $form . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` )
124+ . first ( )
125+ . focus ( )
126+ . val ( 'test' ) ;
127+
128+ screen = 'sm' ;
129+ resizeCallbacks . fire ( ) ;
130+
131+ const formData = $form . dxForm ( 'instance' ) . option ( 'formData' ) ;
132+
133+ assert . deepEqual ( formData , { name : 'test' } , 'textbox value updates' ) ;
134+ } ) ;
135+
136+ QUnit . testInActiveWindow ( 'Form\'s textarea input saves value on refresh (T404958)' , function ( assert ) {
137+ let screen = 'md' ;
138+ const $form = $ ( '#form' ) . dxForm ( {
139+ screenByWidth : function ( ) {
140+ return screen ;
141+ } ,
142+ colCountByScreen : {
143+ sm : 1 ,
144+ md : 2
145+ } ,
146+ items : [
147+ {
148+ dataField : 'name' ,
149+ editorType : 'dxTextArea'
150+ }
151+ ]
152+ } ) ;
153+
154+ $form . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` )
117155 . first ( )
118156 . focus ( )
119157 . val ( 'test' ) ;
120158
121159 screen = 'sm' ;
122160 resizeCallbacks . fire ( ) ;
123161
124- const formData = $formContainer . dxForm ( 'instance' ) . option ( 'formData' ) ;
162+ const formData = $form . dxForm ( 'instance' ) . option ( 'formData' ) ;
125163
126- assert . deepEqual ( formData , { name : 'test' } , 'value updates' ) ;
164+ assert . deepEqual ( formData , { name : 'test' } , 'textarea value updates' ) ;
127165} ) ;
128166
129167QUnit . test ( 'Check field width on render form with colspan' , function ( assert ) {
@@ -4916,39 +4954,124 @@ QUnit.module('reset', () => {
49164954 assert . strictEqual ( summaryItemsAfterValidate . length , 2 , 'form has validation summary after validation' ) ;
49174955 } ) ;
49184956
4919- QUnit . test ( 'DropDownBox should not lose its value if form resized (T1196835)' , function ( assert ) {
4920- let screen = 'lg' ;
4921-
4922- const value = 'VINET' ;
4923- const text = 'Vins et alcools Chevalier (France)' ;
4924- const $form = $ ( '#form' ) . dxForm ( {
4925- formData : { CustomerID : value } ,
4926- screenByWidth : function ( ) { return screen ; } ,
4927- colCountByScreen : {
4928- sm : 1 ,
4929- lg : 2
4930- } ,
4931- items : [
4932- {
4933- itemType : 'simple' ,
4934- cssClass : 'test-ddbox' ,
4935- dataField : 'CustomerID' ,
4936- editorOptions : {
4937- displayExpr : 'Text' ,
4938- valueExpr : 'Value' ,
4939- showClearButton : true ,
4940- dataSource : [ { Value : value , Text : text } ] ,
4957+ [
4958+ 'dxSelectBox' ,
4959+ 'dxDropDownBox'
4960+ ] . forEach ( ( editorType ) => {
4961+ QUnit . test ( `Focused ${ editorType } should not lose its value when the form is resized (T1196835)` , function ( assert ) {
4962+ let screen = 'lg' ;
4963+
4964+ const name = 'VINET' ;
4965+ const value = 'Vins et alcools Chevalier (France)' ;
4966+ const form = $ ( '#form' ) . dxForm ( {
4967+ formData : { name : name } ,
4968+ screenByWidth : function ( ) { return screen ; } ,
4969+ colCountByScreen : {
4970+ sm : 1 ,
4971+ lg : 2
4972+ } ,
4973+ items : [
4974+ {
4975+ itemType : 'simple' ,
4976+ dataField : 'name' ,
4977+ editorOptions : {
4978+ displayExpr : 'Text' ,
4979+ valueExpr : 'Value' ,
4980+ showClearButton : true ,
4981+ dataSource : [ { Value : name , Text : value } ] ,
4982+ } ,
4983+ editorType,
49414984 } ,
4942- editorType : 'dxDropDownBox' ,
4985+ ]
4986+ } ) . dxForm ( 'instance' ) ;
4987+
4988+ const dropDownEditor = form . getEditor ( 'name' ) ;
4989+
4990+ screen = 'sm' ;
4991+ dropDownEditor . focus ( ) ;
4992+ resizeCallbacks . fire ( ) ;
4993+
4994+ assert . strictEqual ( $ ( form . getEditor ( 'name' ) . field ( ) ) . val ( ) , value , `${ editorType } contains expected value` ) ;
4995+ } ) ;
4996+
4997+ QUnit . test ( `Focused ${ editorType } inside a tabbed item should not lose its value when the form is resized (T1196835)` , function ( assert ) {
4998+ let screen = 'lg' ;
4999+
5000+ const name = 'VINET' ;
5001+ const value = 'Vins et alcools Chevalier (France)' ;
5002+ const form = $ ( '#form' ) . dxForm ( {
5003+ formData : { name : name } ,
5004+ screenByWidth : function ( ) { return screen ; } ,
5005+ colCountByScreen : {
5006+ sm : 1 ,
5007+ lg : 2
49435008 } ,
4944- ]
5009+ items : [ {
5010+ itemType : 'tabbed' ,
5011+ tabs : [ {
5012+ title : 'Phone' ,
5013+ colCount : 1 ,
5014+ items : [ {
5015+ itemType : 'simple' ,
5016+ dataField : 'name' ,
5017+ editorOptions : {
5018+ displayExpr : 'Text' ,
5019+ valueExpr : 'Value' ,
5020+ showClearButton : true ,
5021+ dataSource : [ { Value : name , Text : value } ] ,
5022+ } ,
5023+ editorType,
5024+ } ] ,
5025+ } ] ,
5026+ } ] ,
5027+ } ) . dxForm ( 'instance' ) ;
5028+
5029+ const dropDownEditor = form . getEditor ( 'name' ) ;
5030+
5031+ screen = 'sm' ;
5032+ dropDownEditor . focus ( ) ;
5033+ resizeCallbacks . fire ( ) ;
5034+
5035+ assert . strictEqual ( $ ( form . getEditor ( 'name' ) . field ( ) ) . val ( ) , value , `${ editorType } contains expected value` ) ;
49455036 } ) ;
4946- const $input = $form . find ( `.test-ddbox .${ EDITOR_INPUT_CLASS } ` ) ;
49475037
4948- screen = 'sm' ;
4949- $input . focus ( ) ;
4950- resizeCallbacks . fire ( ) ;
5038+ QUnit . test ( `${ editorType } inside a tabbed item and focused tab should not lose its value when the form is resized (T1196835)` , function ( assert ) {
5039+ let screen = 'lg' ;
49515040
4952- assert . strictEqual ( $input . val ( ) , text , 'ddBox contain correct value' ) ;
5041+ const name = 'VINET' ;
5042+ const value = 'Vins et alcools Chevalier (France)' ;
5043+ const form = $ ( '#form' ) . dxForm ( {
5044+ formData : { name : name } ,
5045+ screenByWidth : function ( ) { return screen ; } ,
5046+ colCountByScreen : {
5047+ sm : 1 ,
5048+ lg : 2
5049+ } ,
5050+ items : [ {
5051+ itemType : 'tabbed' ,
5052+ tabs : [ {
5053+ title : 'Phone' ,
5054+ colCount : 1 ,
5055+ items : [ {
5056+ itemType : 'simple' ,
5057+ dataField : 'name' ,
5058+ editorOptions : {
5059+ displayExpr : 'Text' ,
5060+ valueExpr : 'Value' ,
5061+ showClearButton : true ,
5062+ dataSource : [ { Value : name , Text : value } ] ,
5063+ } ,
5064+ editorType,
5065+ } ] ,
5066+ } ] ,
5067+ } ] ,
5068+ } ) . dxForm ( 'instance' ) ;
5069+
5070+ screen = 'sm' ;
5071+ $ ( form . element ( ) ) . find ( `.${ TABPANEL_CLASS } ` ) . focus ( ) ;
5072+ resizeCallbacks . fire ( ) ;
5073+
5074+ assert . strictEqual ( $ ( form . getEditor ( 'name' ) . field ( ) ) . val ( ) , value , `${ editorType } contains expected value` ) ;
5075+ } ) ;
49535076 } ) ;
49545077} ) ;
0 commit comments