Skip to content

Commit

Permalink
update code based on reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkithelegendarypokemonster committed Jul 18, 2024
1 parent c6f33f8 commit 85ecf61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/devextreme/js/ui/splitter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export type ResizeStartEvent<TKey = any> = Cancelable & NativeEventInfo<dxSplitt
* @type object
* @inherits Cancelable,NativeEventInfo,_ui_splitter_ResizeInfo
*/
export type ResizeEndEvent<TKey = any> = Cancelable & NativeEventInfo<dxSplitter<TKey>, KeyboardEvent | PointerEvent | MouseEvent | TouchEvent> & ResizeInfo;
export type ResizeEndEvent<TKey = any> = NativeEventInfo<dxSplitter<TKey>, KeyboardEvent | PointerEvent | MouseEvent | TouchEvent> & ResizeInfo;

/**
* @docid _ui_splitter_ItemCollapsedEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2537,22 +2537,18 @@ QUnit.module('Visibility of control elements', {
});

QUnit.module('Events', moduleConfig, () => {
QUnit.test('should output correct size value for panes in onResizeEnd event (T1240125)', function(assert) {
const resizeHandlerStub = sinon.stub().callsFake(function(eventArgs) {
// Access the items and their sizes from eventArgs if that's how they're passed
const newItems = eventArgs.component.option('items');
assert.notStrictEqual(newItems[0].size, oldItems, 'Size of the first item should be updated');
});

QUnit.test('items sizes should be already updated when onResizeEnd is raised (T1240125)', function(assert) {
this.reinit({
onResizeEnd: resizeHandlerStub,
onResizeEnd: (eventArgs) => {
const newItems = eventArgs.component.option('items');
assert.strictEqual(newItems[0].size, firstPaneInitialSize + delta, 'Size of the first item should be updated');
},
dataSource: [{ text: 'Pane_1' }, { text: 'Pane_2' }]
});
const oldItems = this.instance.option('items')[0].size;
const firstPaneInitialSize = this.instance.option('items')[0].size;
const delta = 90;
const pointer = pointerMock(this.getResizeHandles(false).eq(0));
pointer.start().dragStart().drag(90, 0).dragEnd();

assert.ok(resizeHandlerStub.called, 'onResizeEnd should be called after resizing');
pointer.start().dragStart().drag(delta, 0).dragEnd();
});

['onResizeStart', 'onResize', 'onResizeEnd'].forEach(eventHandler => {
Expand Down Expand Up @@ -2966,29 +2962,6 @@ QUnit.module('Events', moduleConfig, () => {
this.assertLayout([50, 50]);
assert.true(resizeEvent.event.cancel);
});

QUnit.test('onResizeEnd event should be cancellable', function(assert) {
let resizeEvent;
this.reinit({
width: 408,
height: 408,
dataSource: [{ size: '200px' }, { size: '200px' }],
onResizeEnd: function(e) {
resizeEvent = e;
e.cancel = true;
},
});

const pointer = pointerMock(this.getResizeHandles().eq(0));
pointer.start().dragStart().drag(100, 100).dragEnd();

const firstPaneSize = this.instance.option('items[0].size');
const secondPaneSize = this.instance.option('items[1].size');

assert.strictEqual(firstPaneSize, 200);
assert.strictEqual(secondPaneSize, 200);
assert.true(resizeEvent.event.cancel);
});
});

QUnit.module('Nested Splitters', moduleConfig, () => {
Expand Down

0 comments on commit 85ecf61

Please sign in to comment.