Skip to content

Commit 2c207f4

Browse files
Button: onClick function should be triggered when custom template is used Enter, Space keys are pressed in Angular & Vue (DevExpress#29462)
1 parent c4e8d89 commit 2c207f4

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[] {
@@ -166,17 +165,15 @@ export class Button extends InfernoWrapperComponent<ButtonProps> {
166165
if (result?.cancel) {
167166
return result;
168167
}
168+
169169
if (keyName === 'space' || which === 'space' || keyName === 'enter' || which === 'enter') {
170170
originalEvent.preventDefault();
171-
this.emitClickEvent();
171+
172+
this.onWidgetClick(originalEvent);
172173
}
173174
return undefined;
174175
}
175176

176-
emitClickEvent(): void {
177-
this.contentRef.current!.click();
178-
}
179-
180177
get aria(): Record<string, string> {
181178
const {
182179
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)