Skip to content

Commit c33ba6d

Browse files
Button: onClick function should be triggered when custom template is used Enter, Space keys are pressed in Angular & Vue (T1260670, T1260357) (DevExpress#29461)
1 parent 9040cb6 commit c33ba6d

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

packages/devextreme/js/__internal/ui/button/button.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export class Button extends InfernoWrapperComponent<ButtonProps> {
8080
this.onInactive = this.onInactive.bind(this);
8181
this.onWidgetClick = this.onWidgetClick.bind(this);
8282
this.keyDown = this.keyDown.bind(this);
83-
this.emitClickEvent = this.emitClickEvent.bind(this);
8483
}
8584

8685
createEffects(): InfernoEffect[] {
@@ -165,17 +164,15 @@ export class Button extends InfernoWrapperComponent<ButtonProps> {
165164
if (result?.cancel) {
166165
return result;
167166
}
167+
168168
if (keyName === 'space' || which === 'space' || keyName === 'enter' || which === 'enter') {
169169
originalEvent.preventDefault();
170-
this.emitClickEvent();
170+
171+
this.onWidgetClick(originalEvent);
171172
}
172173
return undefined;
173174
}
174175

175-
emitClickEvent(): void {
176-
this.contentRef.current!.click();
177-
}
178-
179176
get aria(): Record<string, string> {
180177
const {
181178
icon,

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -401,24 +401,6 @@ QUnit.module('Button', function() {
401401
assert.equal(clickFired, 2, 'press space on button call click action');
402402
});
403403

404-
QUnit.test('click event is fired on "enter" press', function(assert) {
405-
const $element = $('#button').dxButton({
406-
focusStateEnabled: true
407-
});
408-
const handler = sinon.spy();
409-
410-
$element.on('click', handler);
411-
412-
const keyboard = keyboardMock($element);
413-
414-
$element.trigger('focusin');
415-
keyboard.keyDown('enter');
416-
assert.strictEqual(handler.callCount, 1, 'press enter on button call click action');
417-
418-
keyboard.keyDown('space');
419-
assert.strictEqual(handler.callCount, 2, 'press space on button call click action');
420-
});
421-
422404
QUnit.test('arguments on key press', function(assert) {
423405
const clickHandler = sinon.spy();
424406

0 commit comments

Comments
 (0)