|
@@ -305,33 +305,39 @@ export class Dialog<T> extends Widget {
|
|
|
case 37: {
|
|
|
// Left arrow
|
|
|
const activeEl = document.activeElement;
|
|
|
- let idx = this._buttonNodes.indexOf(activeEl as HTMLElement) - 1;
|
|
|
|
|
|
- // Handle a left arrows on the first button
|
|
|
- if (idx < 0) {
|
|
|
- idx = this._buttonNodes.length - 1;
|
|
|
- }
|
|
|
+ if (activeEl instanceof HTMLButtonElement) {
|
|
|
+ let idx = this._buttonNodes.indexOf(activeEl as HTMLElement) - 1;
|
|
|
|
|
|
- const node = this._buttonNodes[idx];
|
|
|
- event.stopPropagation();
|
|
|
- event.preventDefault();
|
|
|
- node.focus();
|
|
|
+ // Handle a left arrows on the first button
|
|
|
+ if (idx < 0) {
|
|
|
+ idx = this._buttonNodes.length - 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ const node = this._buttonNodes[idx];
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ node.focus();
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case 39: {
|
|
|
// Right arrow
|
|
|
const activeEl = document.activeElement;
|
|
|
- let idx = this._buttonNodes.indexOf(activeEl as HTMLElement) + 1;
|
|
|
|
|
|
- // Handle a right arrows on the last button
|
|
|
- if (idx == this._buttons.length) {
|
|
|
- idx = 0;
|
|
|
- }
|
|
|
+ if (activeEl instanceof HTMLButtonElement) {
|
|
|
+ let idx = this._buttonNodes.indexOf(activeEl as HTMLElement) + 1;
|
|
|
|
|
|
- const node = this._buttonNodes[idx];
|
|
|
- event.stopPropagation();
|
|
|
- event.preventDefault();
|
|
|
- node.focus();
|
|
|
+ // Handle a right arrows on the last button
|
|
|
+ if (idx == this._buttons.length) {
|
|
|
+ idx = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ const node = this._buttonNodes[idx];
|
|
|
+ event.stopPropagation();
|
|
|
+ event.preventDefault();
|
|
|
+ node.focus();
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case 9: {
|