Skip to content

Commit 0b422d2

Browse files
committed
fix after review
1 parent 5434c61 commit 0b422d2

3 files changed

Lines changed: 87 additions & 24 deletions

File tree

packages/devextreme/js/__internal/ui/list/list.base.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,10 @@ export class ListBase extends CollectionWidget<ListBaseProperties, Item> {
10951095
on(eventName: string | { [key: string]: Function }, eventHandler?: Function): this {
10961096
const result = super.on(eventName, eventHandler);
10971097

1098-
const isItemSwipeOn = eventName === 'itemSwipe'
1099-
|| (isPlainObject(eventName) && Object.prototype.hasOwnProperty.call(eventName, 'itemSwipe'));
1098+
const hasItemSwipeHandler = eventName === 'itemSwipe'
1099+
|| (isPlainObject(eventName) && ('itemSwipe' in eventName));
11001100

1101-
if (isItemSwipeOn) {
1101+
if (hasItemSwipeHandler) {
11021102
this._updateSwipeEventSubscription();
11031103
}
11041104

packages/devextreme/playground/jquery.html

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,83 @@ <h1 style="position: fixed; left: 0; top: 0; clip: rect(1px, 1px, 1px, 1px);">Te
4949
<select id="theme-selector" style="display: block;">
5050
</select>
5151
<br />
52-
<div id="button"></div>
52+
<div id="simpleList"></div>
5353
<script>
54-
$(() => {
55-
$("#button").dxButton({
56-
text: 'Click me!',
57-
onClick: () => { alert("clicked"); }
58-
});
59-
});
54+
$(() => {
55+
const tasks = [
56+
{ id: 1, text: 'Prepare 2016 Financial' },
57+
{ id: 2, text: 'Prepare 2016 Marketing Plan' },
58+
{ id: 3, text: 'Update Personnel Files' },
59+
{ id: 4, text: 'Review Health Insurance Options Under the Affordable Care Act' },
60+
{ id: 5, text: 'New Brochures' },
61+
{ id: 6, text: '2016 Brochure Designs' },
62+
{ id: 7, text: 'Brochure Design Review' },
63+
{ id: 8, text: 'Website Re-Design Plan' },
64+
{ id: 9, text: 'Rollout of New Website and Marketing Brochures' },
65+
{ id: 10, text: 'Create 2012 Sales Report' },
66+
{ id: 11, text: 'Direct vs Online Sales Comparison Report' },
67+
{ id: 12, text: 'Review 2012 Sales Report and Approve 2016 Plans' },
68+
{ id: 13, text: 'Submit Signed NDA' },
69+
{ id: 14, text: 'Update Revenue Projections' },
70+
{ id: 15, text: 'Review Revenue Projections' },
71+
{ id: 16, text: 'Comment on Revenue Projections' },
72+
{ id: 17, text: 'Scan Health Insurance Forms' },
73+
{ id: 18, text: 'Sign Health Insurance Forms' },
74+
{ id: 19, text: 'Follow up with West Coast Stores' },
75+
{ id: 20, text: 'Follow up with East Coast Stores' },
76+
{ id: 21, text: 'Submit Refund Report for 2016 Recall' },
77+
{ id: 22, text: 'Give Final Approval for Refunds' },
78+
{ id: 23, text: 'Prepare Product Recall Report' },
79+
{ id: 24, text: 'Review Product Recall Report by Engineering Team' },
80+
{ id: 25, text: 'Review Training Course for any Omissions' },
81+
{ id: 26, text: 'Review Overtime Report' },
82+
{ id: 27, text: 'Submit Overtime Request Forms' },
83+
{ id: 28, text: 'Overtime Approval Guidelines' },
84+
{ id: 29, text: 'Create Report on Customer Feedback' },
85+
{ id: 30, text: 'Review Customer Feedback Report' },
86+
{ id: 31, text: 'Customer Feedback Report Analysis' },
87+
{ id: 32, text: 'Prepare Shipping Cost Analysis Report' },
88+
{ id: 33, text: 'Complete Shipper Selection Form' },
89+
{ id: 34, text: 'Upgrade Server Hardware' },
90+
{ id: 35, text: 'Upgrade Personal Computers' },
91+
{ id: 36, text: 'Approve Personal Computer Upgrade Plan' },
92+
{ id: 37, text: 'Estimate Time Required to Touch-Enable Apps' },
93+
{ id: 38, text: 'Report on Tranistion to Touch-Based Apps' },
94+
{ id: 39, text: 'Try New Touch-Enabled WinForms Apps' },
95+
{ id: 40, text: 'Site Up-Time Report' },
96+
{ id: 41, text: 'Review Site Up-Time Report' },
97+
{ id: 42, text: 'Review Online Sales Report' },
98+
{ id: 43, text: 'Determine New Online Marketing Strategy' },
99+
{ id: 44, text: 'Submit New Website Design' },
100+
{ id: 45, text: 'Create Icons for Website' },
101+
{ id: 46, text: 'Review PSDs for New Website' },
102+
{ id: 47, text: 'Create New Shopping Cart' },
103+
{ id: 48, text: 'Launch New Website' },
104+
{ id: 49, text: 'Update Customer Shipping Profiles' },
105+
{ id: 50, text: 'Create New Shipping Return Labels' }
106+
];
107+
108+
const listWidget = $('#simpleList').dxList({
109+
items: tasks,
110+
height: 500,
111+
focusStateEnabled: false,
112+
activeStateEnabled: false,
113+
114+
// CASE 1 onItemSwipe
115+
onItemSwipe: () => {console.log('onItemSwipe')},
116+
117+
// CASE 2 Menu
118+
// menuMode: "slide",
119+
// menuItems: [{ text: "foo", action: (e) => {}}],
120+
121+
// CASE 3 Deleting items by swipe
122+
// allowItemDeleting: true,
123+
// itemDeleteMode: 'swipe',
124+
125+
}).dxList('instance');
126+
127+
listWidget.on('itemSwipe', () => {console.log('itemSwipe')})
128+
});
60129
</script>
61130
</div>
62131
</body>

packages/devextreme/testing/tests/DevExpress.ui.widgets/listParts/commonTests.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4809,7 +4809,7 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48094809

48104810
const getFirstListItemAndTextNode = ($list) => {
48114811
const $item = $list.find(`.${LIST_ITEM_CLASS}`).eq(0);
4812-
const textNode = $list.find(`.${LIST_ITEM_CONTENT_CLASS}`).eq(0).get(0).firstChild;
4812+
const textNode = $item.find(`.${LIST_ITEM_CONTENT_CLASS}`).eq(0).get(0).firstChild;
48134813

48144814
return { $item, textNode };
48154815
};
@@ -4820,16 +4820,15 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48204820
});
48214821

48224822
const { $item, textNode } = getFirstListItemAndTextNode(this.element);
4823-
assert.ok(!!textNode, 'text node found in list item');
4824-
if(!textNode) return;
4823+
4824+
assert.strictEqual(!!textNode, true, 'text node found in list item');
48254825

48264826
selectTextNodePart(textNode, 0, 4);
48274827
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists before drag');
48284828

48294829
pointerMock($item).start().down(0, 0).move(50, 0).up();
48304830

4831-
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection is preserved after horizontal drag');
4832-
window.getSelection().removeAllRanges();
4831+
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists after drag');
48334832
});
48344833

48354834
QUnit.test('text selection should be preserved after onItemSwipe handler is removed from options', function(assert) {
@@ -4842,16 +4841,14 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48424841
list.option('onItemSwipe', null);
48434842

48444843
const { $item, textNode } = getFirstListItemAndTextNode(this.element);
4845-
assert.ok(!!textNode, 'text node found in list item');
4846-
if(!textNode) return;
4844+
assert.strictEqual(!!textNode, true, 'text node found in list item');
48474845

48484846
selectTextNodePart(textNode, 0, 4);
48494847
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists before drag');
48504848

48514849
pointerMock($item).start().down(0, 0).move(50, 0).up();
48524850

4853-
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection is preserved after drag when swipe handler is removed');
4854-
window.getSelection().removeAllRanges();
4851+
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists after drag');
48554852
});
48564853

48574854
QUnit.test('text selection should reflect itemSwipe on/off subscription state', function(assert) {
@@ -4863,9 +4860,7 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48634860

48644861
const { $item, textNode } = getFirstListItemAndTextNode(this.element);
48654862

4866-
assert.ok(!!textNode, 'text node found in list item');
4867-
4868-
if(!textNode) return;
4863+
assert.strictEqual(!!textNode, true, 'text node found in list item');
48694864

48704865
list.on('itemSwipe', sinon.spy());
48714866

@@ -4883,8 +4878,7 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48834878

48844879
pointerMock($item).start().down(0, 0).move(50, 0).up();
48854880

4886-
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection is preserved after drag when swipe handler is removed');
4887-
window.getSelection().removeAllRanges();
4881+
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists after drag when swipe handler is removed');
48884882
});
48894883
});
48904884

0 commit comments

Comments
 (0)