Keyboard shortcuts and accessibility

This commit is contained in:
Scott Nonnenberg 2019-11-07 13:36:16 -08:00
parent 8590a047c7
commit 20a892247f
87 changed files with 3652 additions and 711 deletions

View file

@ -0,0 +1,34 @@
diff --git a/node_modules/react-contextmenu/modules/ContextMenu.js b/node_modules/react-contextmenu/modules/ContextMenu.js
index 622a1f9..61c8e70 100644
--- a/node_modules/react-contextmenu/modules/ContextMenu.js
+++ b/node_modules/react-contextmenu/modules/ContextMenu.js
@@ -226,6 +226,9 @@ var ContextMenu = function (_AbstractMenu) {
if (this.state.isVisible) {
var wrapper = window.requestAnimationFrame || setTimeout;
+ if (!this.previousFocus) {
+ this.previousFocus = document.activeElement;
+ }
wrapper(function () {
var _state = _this2.state,
@@ -242,12 +245,19 @@ var ContextMenu = function (_AbstractMenu) {
_this2.menu.style.left = left + 'px';
_this2.menu.style.opacity = 1;
_this2.menu.style.pointerEvents = 'auto';
+
+ _this2.menu.focus();
});
});
} else {
if (!this.menu) return;
this.menu.style.opacity = 0;
this.menu.style.pointerEvents = 'none';
+
+ if (this.previousFocus && this.previousFocus.focus) {
+ this.previousFocus.focus();
+ this.previousFocus = null;
+ }
}
}
}, {

View file

@ -70,7 +70,7 @@ index 262776b..156cf0f 100644
this._cellHeightCache[key] = height;
this._cellWidthCache[key] = width;
diff --git a/node_modules/react-virtualized/dist/commonjs/Grid/Grid.js b/node_modules/react-virtualized/dist/commonjs/Grid/Grid.js
index e1b959a..8c5fb6b 100644
index e1b959a..7410c0a 100644
--- a/node_modules/react-virtualized/dist/commonjs/Grid/Grid.js
+++ b/node_modules/react-virtualized/dist/commonjs/Grid/Grid.js
@@ -132,6 +132,9 @@ var Grid = function (_React$PureComponent) {
@ -155,7 +155,7 @@ index e1b959a..8c5fb6b 100644
});
this._maybeCallOnScrollbarPresenceChange();
@@ -584,6 +616,67 @@ var Grid = function (_React$PureComponent) {
@@ -584,6 +616,65 @@ var Grid = function (_React$PureComponent) {
}
}
@ -178,7 +178,7 @@ index e1b959a..8c5fb6b 100644
+ this._hasScrolledToRowTarget = true;
+ }
+
+ if (scrollToColumn >= 0 && !this._hasScrolledToColumnTarget) {
+ if (scrollToColumn >= 0 && !this._hasScrolledToColumnTarget && scrollLeft + width <= totalColumnsWidth) {
+ const scrollRight = scrollLeft + width;
+ const targetColumn = instanceProps.columnSizeAndPositionManager.getSizeAndPositionOfCell(scrollToColumn);
+
@ -192,10 +192,10 @@ index e1b959a..8c5fb6b 100644
+
+ if (isVisible) {
+ const maxScroll = totalColumnsWidth - width;
+ this._hasScrolledToColumnTarget = targetColumn.offset === scrollLeft || (targetColumn.offset < totalColumnsColumsHeight && scrollLeft >= maxScroll);
+ this._hasScrolledToColumnTarget = (scrollLeft >= maxScroll || targetColumn.offset === scrollLeft);
+ }
+ }
+ if (scrollToRow >= 0 && !this._hasScrolledToRowTarget) {
+ if (scrollToRow >= 0 && !this._hasScrolledToRowTarget && scrollTop + height <= totalRowsHeight) {
+ const scrollBottom = scrollTop + height;
+ const targetRow = instanceProps.rowSizeAndPositionManager.getSizeAndPositionOfCell(scrollToRow);
+ const maxScroll = totalRowsHeight - height;
@ -213,9 +213,7 @@ index e1b959a..8c5fb6b 100644
+ }
+
+ if (isVisible) {
+ // We check the target row's offset against the totalRowsHeight because sometimes the math can be a bit off,
+ // and the target row has an offset greater than our calculated total height.
+ this._hasScrolledToRowTarget = targetRow.offset === scrollTop || (targetRow.offset < totalRowsHeight && scrollTop >= maxScroll);
+ this._hasScrolledToRowTarget = (scrollTop >= maxScroll || targetRow.offset === scrollTop);
+ }
+ }
+ }
@ -223,7 +221,7 @@ index e1b959a..8c5fb6b 100644
// Special case where the previous size was 0:
// In this case we don't show any windowed cells at all.
// So we should always recalculate offset afterwards.
@@ -594,6 +687,8 @@ var Grid = function (_React$PureComponent) {
@@ -594,6 +685,8 @@ var Grid = function (_React$PureComponent) {
if (this._recomputeScrollLeftFlag) {
this._recomputeScrollLeftFlag = false;
this._updateScrollLeftForScrollToColumn(this.props);
@ -232,7 +230,7 @@ index e1b959a..8c5fb6b 100644
} else {
(0, _updateScrollIndexHelper2.default)({
cellSizeAndPositionManager: instanceProps.columnSizeAndPositionManager,
@@ -616,6 +711,8 @@ var Grid = function (_React$PureComponent) {
@@ -616,6 +709,8 @@ var Grid = function (_React$PureComponent) {
if (this._recomputeScrollTopFlag) {
this._recomputeScrollTopFlag = false;
this._updateScrollTopForScrollToRow(this.props);
@ -241,7 +239,7 @@ index e1b959a..8c5fb6b 100644
} else {
(0, _updateScrollIndexHelper2.default)({
cellSizeAndPositionManager: instanceProps.rowSizeAndPositionManager,
@@ -635,19 +732,50 @@ var Grid = function (_React$PureComponent) {
@@ -635,19 +730,50 @@ var Grid = function (_React$PureComponent) {
});
}
@ -296,7 +294,7 @@ index e1b959a..8c5fb6b 100644
});
}
@@ -909,6 +1037,11 @@ var Grid = function (_React$PureComponent) {
@@ -909,6 +1035,11 @@ var Grid = function (_React$PureComponent) {
visibleRowIndices: visibleRowIndices
});
@ -308,7 +306,7 @@ index e1b959a..8c5fb6b 100644
// update the indices
this._columnStartIndex = columnStartIndex;
this._columnStopIndex = columnStopIndex;
@@ -962,7 +1095,11 @@ var Grid = function (_React$PureComponent) {
@@ -962,7 +1093,11 @@ var Grid = function (_React$PureComponent) {
var scrollLeft = _ref6.scrollLeft,
scrollTop = _ref6.scrollTop,
totalColumnsWidth = _ref6.totalColumnsWidth,
@ -321,7 +319,7 @@ index e1b959a..8c5fb6b 100644
this._onScrollMemoizer({
callback: function callback(_ref7) {
@@ -973,19 +1110,26 @@ var Grid = function (_React$PureComponent) {
@@ -973,19 +1108,26 @@ var Grid = function (_React$PureComponent) {
onScroll = _props7.onScroll,
width = _props7.width;
@ -351,7 +349,7 @@ index e1b959a..8c5fb6b 100644
}
});
}
@@ -1325,6 +1469,15 @@ var Grid = function (_React$PureComponent) {
@@ -1325,6 +1467,15 @@ var Grid = function (_React$PureComponent) {
var totalColumnsWidth = instanceProps.columnSizeAndPositionManager.getTotalSize();
var scrollBarSize = instanceProps.scrollbarSizeMeasured && totalColumnsWidth > width ? instanceProps.scrollbarSize : 0;