-
Notifications
You must be signed in to change notification settings - Fork 664
Form: fields should not exceed group column width when many items are selected (T1326645) #33268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 26_1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,10 +5,12 @@ import responsiveBoxScreenMock from '../../helpers/responsiveBoxScreenMock.js'; | |||||||||||||||||||||||||||||||||
| import { isRenderer } from 'core/utils/type'; | ||||||||||||||||||||||||||||||||||
| import config from 'core/config'; | ||||||||||||||||||||||||||||||||||
| import 'ui/form'; | ||||||||||||||||||||||||||||||||||
| import { FIELD_ITEM_CLASS, | ||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||
| FORM_CLASS, | ||||||||||||||||||||||||||||||||||
| FORM_FIELD_ITEM_COL_CLASS, | ||||||||||||||||||||||||||||||||||
| FORM_GROUP_CLASS, | ||||||||||||||||||||||||||||||||||
| FIELD_ITEM_CLASS, | ||||||||||||||||||||||||||||||||||
| FIELD_ITEM_LABEL_CLASS, | ||||||||||||||||||||||||||||||||||
| FIELD_ITEM_CONTENT_CLASS, | ||||||||||||||||||||||||||||||||||
| FIELD_ITEM_LABEL_CONTENT_CLASS, | ||||||||||||||||||||||||||||||||||
| FORM_GROUP_CAPTION_CLASS, | ||||||||||||||||||||||||||||||||||
|
|
@@ -24,6 +26,9 @@ import ValidationEngine from 'ui/validation_engine'; | |||||||||||||||||||||||||||||||||
| import 'ui/text_area'; | ||||||||||||||||||||||||||||||||||
| import 'ui/radio_group'; | ||||||||||||||||||||||||||||||||||
| import 'ui/switch'; | ||||||||||||||||||||||||||||||||||
| import 'ui/tag_box'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import 'fluent_blue_light.css!'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const FORM_GROUP_CONTENT_CLASS = 'dx-form-group-content'; | ||||||||||||||||||||||||||||||||||
| const FORM_GROUP_CUSTOM_CAPTION_CLASS = 'dx-form-group-custom-caption'; | ||||||||||||||||||||||||||||||||||
|
|
@@ -142,7 +147,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| assert.equal(rootLayoutManager.option('width'), 100, 'Correct width'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('Form isn\'t refresh on dimension changed if colCount is auto', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('Form should not refresh on dimension changed if colCount is auto', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $formContainer = $('#form').dxForm({ | ||||||||||||||||||||||||||||||||||
| colCount: 'auto', | ||||||||||||||||||||||||||||||||||
| items: [ | ||||||||||||||||||||||||||||||||||
|
|
@@ -157,10 +162,10 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| resizeCallbacks.fire(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert.equal(refreshStub.callCount, 0, 'don\'t refresh on resize if colCount is auto'); | ||||||||||||||||||||||||||||||||||
| assert.equal(refreshStub.callCount, 0, 'did not refresh on resize if colCount is auto'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('Form doesn\'t refresh on dimension changed if colCount is not auto', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('Form should not refresh on dimension changed if colCount is not auto', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $formContainer = $('#form').dxForm({ | ||||||||||||||||||||||||||||||||||
| items: [ | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
|
@@ -175,7 +180,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| resizeCallbacks.fire(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert.equal(refreshStub.callCount, 0, 'do not refresh on resize if colCount isn\'t auto'); | ||||||||||||||||||||||||||||||||||
| assert.equal(refreshStub.callCount, 0, 'did not refresh on resize if colCount is not auto'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('Render read only form', function(assert) { | ||||||||||||||||||||||||||||||||||
|
|
@@ -217,7 +222,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| assert.equal($fieldItems.length, 5, '4 simple items + 1 group item'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('\'readOnly\' is changed in inner components on optionChanged', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('readOnly option is changed in inner components on optionChanged', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $formContainer = $('#form').dxForm({ | ||||||||||||||||||||||||||||||||||
| items: [ | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
|
@@ -227,7 +232,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert.notOk($formContainer.find(`.${FIELD_ITEM_CLASS} .${TEXTEDITOR_CLASS}`).hasClass(READONLY_STATE_CLASS), 'editor isn\'t read only'); | ||||||||||||||||||||||||||||||||||
| assert.notOk($formContainer.find(`.${FIELD_ITEM_CLASS} .${TEXTEDITOR_CLASS}`).hasClass(READONLY_STATE_CLASS), 'editor is not read only'); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| $formContainer.dxForm('instance').option('readOnly', true); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -250,7 +255,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| assert.ok($testContainer.find(`.${FIELD_ITEM_CLASS} .${TEXTEDITOR_CLASS}`).hasClass(READONLY_STATE_CLASS), 'editor is read only'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('\'disable\' is changed in inner components on optionChanged', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('disable option is changed in inner components on optionChanged', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $formContainer = $('#form').dxForm({ | ||||||||||||||||||||||||||||||||||
| items: [ | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
|
@@ -265,7 +270,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| $formContainer.dxForm('instance').option('disabled', false); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert.notOk($formContainer.find(`.${FIELD_ITEM_CLASS} .${TEXTEDITOR_CLASS}`).hasClass('dx-state-disabled'), 'editor isn\'t disabled'); | ||||||||||||||||||||||||||||||||||
| assert.notOk($formContainer.find(`.${FIELD_ITEM_CLASS} .${TEXTEDITOR_CLASS}`).hasClass('dx-state-disabled'), 'editor is not disabled'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('Customize item event', function(assert) { | ||||||||||||||||||||||||||||||||||
|
|
@@ -335,7 +340,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| assert.deepEqual($testContainer.find('.dx-layout-manager').dxLayoutManager('instance').option('layoutData'), { FamousPirate: 'John Morgan' }, 'Correct formData'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('Check data at render with items and change widget\'s value', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('Check data at render with items and change widget value', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $testContainer = $('#form'); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| $testContainer.dxForm({ | ||||||||||||||||||||||||||||||||||
|
|
@@ -348,7 +353,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| assert.deepEqual($testContainer.dxForm('instance').option('formData'), { FamousPirate: 'John Morgan', FamousDetective: 'Sherlock Holmes' }, 'Correct formData'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('Change of editor\'s value changing \'formData\' option', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('Change of editor value changing formData option', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $testContainer = $('#form'); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| $testContainer.dxForm({ | ||||||||||||||||||||||||||||||||||
|
|
@@ -360,7 +365,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| assert.deepEqual($testContainer.dxForm('instance').option('formData'), { FamousPirate: 'Cpt. Jack Sparrow' }, 'Correct formData'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('Update of editor\'s value when formOption is changed and items is defined', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('Update of editor value when formOption is changed and items is defined', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $testContainer = $('#form'); | ||||||||||||||||||||||||||||||||||
| const textBoxes = []; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -710,7 +715,7 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
| assert.equal($editors.eq(1).dxTextBox('option', 'validationBoundary'), undefined); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('button item should have a Form\'s validation group by default', function(assert) { | ||||||||||||||||||||||||||||||||||
| test('button item should have a Form validation group by default', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $testContainer = $('#form'); | ||||||||||||||||||||||||||||||||||
| const form = $testContainer.dxForm({ | ||||||||||||||||||||||||||||||||||
| items: [{ | ||||||||||||||||||||||||||||||||||
|
|
@@ -791,6 +796,44 @@ QUnit.module('Form', () => { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert.equal(templateStub.getCall(0).args[0].name, undefined, 'name argument'); | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| test('TagBox should not exceed group column width when many items are selected (T1326645)', function(assert) { | ||||||||||||||||||||||||||||||||||
| const $form = $('#form').width(600); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| $form.dxForm({ | ||||||||||||||||||||||||||||||||||
| labelLocation: 'left', | ||||||||||||||||||||||||||||||||||
| formData: { | ||||||||||||||||||||||||||||||||||
| tags: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| items: [ | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| itemType: 'group', | ||||||||||||||||||||||||||||||||||
| items: [{ | ||||||||||||||||||||||||||||||||||
| dataField: 'tags', | ||||||||||||||||||||||||||||||||||
| editorType: 'dxTagBox', | ||||||||||||||||||||||||||||||||||
| editorOptions: { | ||||||||||||||||||||||||||||||||||
| items: Array.from({ length: 10 }, (_, i) => ({ | ||||||||||||||||||||||||||||||||||
| id: i + 1, | ||||||||||||||||||||||||||||||||||
| name: `Long item name ${i + 1}`, | ||||||||||||||||||||||||||||||||||
| })), | ||||||||||||||||||||||||||||||||||
| displayExpr: 'name', | ||||||||||||||||||||||||||||||||||
| valueExpr: 'id', | ||||||||||||||||||||||||||||||||||
| multiline: false, | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| }], | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const $group = $form.find(`.${FORM_GROUP_CLASS}`).first(); | ||||||||||||||||||||||||||||||||||
| const $label = $group.find(`.${FIELD_ITEM_LABEL_CLASS}`).first(); | ||||||||||||||||||||||||||||||||||
| const $content = $group.find(`.${FIELD_ITEM_CONTENT_CLASS}`).first(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const groupWidth = $group.outerWidth(); | ||||||||||||||||||||||||||||||||||
| const totalItemWidth = $label.outerWidth() + $content.outerWidth(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| assert.strictEqual(totalItemWidth <= groupWidth, true, `field item content width (${totalItemWidth}) should not exceed group width (${groupWidth})`); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+829
to
+835
|
||||||||||||||||||||||||||||||||||
| const $label = $group.find(`.${FIELD_ITEM_LABEL_CLASS}`).first(); | |
| const $content = $group.find(`.${FIELD_ITEM_CONTENT_CLASS}`).first(); | |
| const groupWidth = $group.outerWidth(); | |
| const totalItemWidth = $label.outerWidth() + $content.outerWidth(); | |
| assert.strictEqual(totalItemWidth <= groupWidth, true, `field item content width (${totalItemWidth}) should not exceed group width (${groupWidth})`); | |
| const $content = $group.find(`.${FIELD_ITEM_CONTENT_CLASS}`).first(); | |
| const groupRect = $group.get(0).getBoundingClientRect(); | |
| const contentRect = $content.get(0).getBoundingClientRect(); | |
| const widthTolerance = 2; | |
| assert.ok( | |
| contentRect.right <= groupRect.right + widthTolerance, | |
| `field item content right edge (${contentRect.right}) should not exceed group right edge (${groupRect.right}) with tolerance ${widthTolerance}px`, | |
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s compare strict values instead of relying on a conditional check. Also, use jQuery methods to retrieve the element’s dimensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
min-width: 0is added only for.dx-field-item-content, but in.dx-flex-layoutboth.dx-field-item-contentand.dx-field-item-content-wrapperare configured as flex items (flex-shrink/grow/basis). If a field uses the wrapper (e.g., when helpText is rendered), the wrapper can still be prevented from shrinking by the defaultmin-width: auto. Consider applyingmin-width: 0to the wrapper as well (or scoping the rule specifically to the flex layout selectors).