Skip to content

Commit 40d55dc

Browse files
authored
Stepper: update connector properties on repaint (T1312793) (#31619)
1 parent ecbce8e commit 40d55dc

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

packages/devextreme/js/__internal/ui/stepper/stepper.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import type {
1717
ItemRenderInfo,
1818
PostprocessRenderItemInfo,
1919
} from '@ts/ui/collection/collection_widget.base';
20+
import type { CollectionWidgetEditProperties } from '@ts/ui/collection/collection_widget.edit';
21+
import type { ConnectorProperties } from '@ts/ui/stepper/connector';
2022
import Connector from '@ts/ui/stepper/connector';
2123
import StepperItem, {
2224
STEP_COMPLETED_CLASS,
2325
STEP_INVALID_ICON,
2426
STEP_VALID_ICON,
2527
} from '@ts/ui/stepper/stepper_item';
2628

27-
import type { CollectionWidgetEditProperties } from '../collection/collection_widget.edit';
28-
2929
export const STEPPER_CLASS = 'dx-stepper';
3030
export const STEP_LIST_CLASS = 'dx-step-list';
3131
export const STEP_CLASS = 'dx-step';
@@ -260,18 +260,26 @@ class Stepper extends CollectionWidgetAsync<StepperProperties> {
260260
super._initMarkup();
261261
}
262262

263-
_renderConnector(): void {
264-
if (this._connector) {
265-
return;
266-
}
267-
263+
_getConnectorOptions(): ConnectorProperties {
268264
const { orientation } = this.option();
269265

270-
this._connector = this._createComponent($('<div>'), Connector, {
266+
return {
271267
orientation,
272268
size: this._getConnectorSize(),
273269
value: this._getConnectorValue(),
274-
});
270+
};
271+
}
272+
273+
_renderConnector(): void {
274+
if (this._connector) {
275+
return;
276+
}
277+
278+
this._connector = this._createComponent(
279+
$('<div>'),
280+
Connector,
281+
this._getConnectorOptions(),
282+
);
275283

276284
$(this.element())
277285
.prepend(this._connector.$element());
@@ -445,6 +453,10 @@ class Stepper extends CollectionWidgetAsync<StepperProperties> {
445453
case 'hintExpr':
446454
this._invalidate();
447455
break;
456+
case 'items':
457+
super._optionChanged(args);
458+
this._connector.option(this._getConnectorOptions());
459+
break;
448460
default:
449461
super._optionChanged(args);
450462
}

packages/devextreme/testing/tests/DevExpress.ui.widgets/stepper.tests.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ QUnit.module('Navigation', moduleConfig, () => {
9797
items: [{}, {}, {}, {}],
9898
selectedIndex: 1,
9999
linear,
100-
onSelectionChanged: function(e) {
100+
onSelectionChanged: function() {
101101
count += 1;
102102
},
103103
});
@@ -310,6 +310,23 @@ QUnit.module('Connector integration', moduleConfig, () => {
310310
assert.deepEqual(this.getConnector().$element().children().length, 1, 'content is not duplicated');
311311
});
312312
});
313+
314+
QUnit.test('connector should update its size on items mutation (T1312793)', function(assert) {
315+
const items = [{}, {}];
316+
317+
this.reinit({ items, width: 100 });
318+
319+
const sizeBefore = this.getConnector().option('size');
320+
321+
assert.roughEqual(sizeBefore, 50, 0.01, 'initial connector size is correct');
322+
323+
items.push({}, {});
324+
this.instance.option('items', items);
325+
326+
const sizeAfter = this.getConnector().option('size');
327+
328+
assert.roughEqual(sizeAfter, 75, 0.01, 'connector size is correct after items mutation');
329+
});
313330
});
314331

315332
QUnit.module('Focus', moduleConfig, () => {

0 commit comments

Comments
 (0)