Skip to content

Commit f6f41ab

Browse files
committed
revrite tests and code optimization
1 parent f1ae953 commit f6f41ab

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,12 @@ export class ListBase extends CollectionWidget<ListBaseProperties, Item> {
132132

133133
_$nextButton!: dxElementWrapper | null;
134134

135-
// eslint-disable-next-line no-restricted-globals
136135
_holdTimer?: ReturnType<typeof setTimeout>;
137136

138-
// eslint-disable-next-line no-restricted-globals
139137
_loadNextPageTimer?: ReturnType<typeof setTimeout>;
140138

141-
// eslint-disable-next-line no-restricted-globals
142139
_showLoadingIndicatorTimer?: ReturnType<typeof setTimeout>;
143140

144-
// eslint-disable-next-line no-restricted-globals
145141
_inkRippleTimer?: ReturnType<typeof setTimeout>;
146142

147143
_isFirstLoadCompleted?: boolean;
@@ -1072,9 +1068,7 @@ export class ListBase extends CollectionWidget<ListBaseProperties, Item> {
10721068
this._refreshItemElements();
10731069
super._postprocessRenderItem(args);
10741070

1075-
if (this.hasActionSubscription('onItemSwipe')) {
1076-
this._attachSwipeEvent($(args.itemElement));
1077-
}
1071+
this._attachSwipeEvent($(args.itemElement));
10781072
}
10791073

10801074
_getElementClassToSkipRefreshId(): string {
@@ -1085,15 +1079,18 @@ export class ListBase extends CollectionWidget<ListBaseProperties, Item> {
10851079
// @ts-expect-error ts-error
10861080
const endEventName = addNamespace(swipeEventEnd, this.NAME);
10871081

1082+
eventsEngine.off($itemElement, endEventName);
10881083
eventsEngine.on($itemElement, endEventName, (e) => {
10891084
this._itemSwipeEndHandler(e);
10901085
});
10911086
}
10921087

10931088
_itemSwipeEndHandler(e: DxEvent & { offset: number }): void {
1094-
this._itemDXEventHandler(e, 'onItemSwipe', {
1095-
direction: e.offset < 0 ? 'left' : 'right',
1096-
});
1089+
if (this.hasActionSubscription('onItemSwipe')) {
1090+
this._itemDXEventHandler(e, 'onItemSwipe', {
1091+
direction: e.offset < 0 ? 'left' : 'right',
1092+
});
1093+
}
10971094
}
10981095

10991096
_nextButtonHandler(): void {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,8 @@ QUnit.module('options changed', moduleSetup, () => {
11391139
swipeItem();
11401140
});
11411141

1142-
QUnit.test('onItemSwipe handler should not be triggered if "allowItemTextSelection" is false on init', function(assert) {
1143-
assert.expect(0);
1142+
QUnit.test('onItemSwipe handler should be triggered if it has in the config', function(assert) {
1143+
assert.expect(1);
11441144

11451145
const swipeHandler = () => {
11461146
assert.ok(true, 'swipe handled');

0 commit comments

Comments
 (0)