signal-desktop/patches/react-contextmenu+2.14.0.patch

139 lines
6.8 KiB
Diff
Raw Normal View History

2019-11-07 21:36:16 +00:00
diff --git a/node_modules/react-contextmenu/modules/ContextMenu.js b/node_modules/react-contextmenu/modules/ContextMenu.js
2024-11-20 00:38:24 +00:00
index 2f88213..d41a53c 100644
2019-11-07 21:36:16 +00:00
--- a/node_modules/react-contextmenu/modules/ContextMenu.js
+++ b/node_modules/react-contextmenu/modules/ContextMenu.js
@@ -81,6 +81,11 @@ var ContextMenu = function (_AbstractMenu) {
x = _e$detail$position.x,
y = _e$detail$position.y;
2024-11-18 19:20:23 +00:00
+ if (x === undefined) {
+ var rect = e.detail.target.getBoundingClientRect();
+ x = rect.x;
+ y = rect.y;
+ }
_this.setState({ isVisible: true, x: x, y: y });
_this.registerHandlers();
@@ -226,6 +231,9 @@ var ContextMenu = function (_AbstractMenu) {
2024-11-18 19:20:23 +00:00
var wrapper = window.requestAnimationFrame || setTimeout;
2019-11-07 21:36:16 +00:00
if (this.state.isVisible) {
+ if (!this.previousFocus) {
+ this.previousFocus = document.activeElement;
+ }
wrapper(function () {
var _state = _this2.state,
2024-11-18 19:20:23 +00:00
x = _state.x,
@@ -240,7 +248,10 @@ var ContextMenu = function (_AbstractMenu) {
2021-09-16 21:51:57 +00:00
_this2.menu.style.top = top + 'px';
2019-11-07 21:36:16 +00:00
_this2.menu.style.left = left + 'px';
_this2.menu.style.opacity = 1;
2021-09-16 21:51:57 +00:00
+ _this2.menu.style.visibility = 'visible';
2019-11-07 21:36:16 +00:00
_this2.menu.style.pointerEvents = 'auto';
+
+ _this2.menu.focus();
});
});
} else {
2024-11-18 19:20:23 +00:00
@@ -248,6 +259,11 @@ var ContextMenu = function (_AbstractMenu) {
if (!_this2.menu) return;
_this2.menu.style.opacity = 0;
_this2.menu.style.pointerEvents = 'none';
2019-11-07 21:36:16 +00:00
+
2024-11-20 00:38:24 +00:00
+ if (_this2.previousFocus && _this2.previousFocus.focus) {
+ _this2.previousFocus.focus();
+ _this2.previousFocus = null;
2024-11-18 19:20:23 +00:00
+ }
});
2019-11-07 21:36:16 +00:00
}
}
diff --git a/node_modules/react-contextmenu/modules/SubMenu.js b/node_modules/react-contextmenu/modules/SubMenu.js
2024-11-20 00:38:24 +00:00
index ad1dc70..4604898 100644
--- a/node_modules/react-contextmenu/modules/SubMenu.js
+++ b/node_modules/react-contextmenu/modules/SubMenu.js
2024-11-18 19:20:23 +00:00
@@ -129,6 +129,7 @@ var SubMenu = function (_AbstractMenu) {
if (_this.props.disabled || _this.state.visible) return;
+ if (_this.opentimer) clearTimeout(_this.opentimer);
_this.opentimer = setTimeout(function () {
return _this.setState({
visible: true,
2024-11-18 19:20:23 +00:00
@@ -142,6 +143,7 @@ var SubMenu = function (_AbstractMenu) {
if (!_this.state.visible) return;
+ if (_this.closetimer) clearTimeout(_this.closetimer);
_this.closetimer = setTimeout(function () {
return _this.setState({
visible: false,
2024-11-18 19:20:23 +00:00
@@ -170,6 +172,15 @@ var SubMenu = function (_AbstractMenu) {
}
};
+ _this.cleanup = function () {
+ _this.subMenu.removeEventListener('transitionend', _this.cleanup);
+ _this.subMenu.style.removeProperty('bottom');
+ _this.subMenu.style.removeProperty('right');
+ _this.subMenu.style.top = 0;
+ _this.subMenu.style.left = '100%';
+ _this.unregisterHandlers();
+ };
+
_this.state = (0, _objectAssign2.default)({}, _this.state, {
visible: false
});
2024-11-20 00:38:24 +00:00
@@ -202,32 +213,28 @@ var SubMenu = function (_AbstractMenu) {
if (this.props.forceOpen || this.state.visible) {
var wrapper = window.requestAnimationFrame || setTimeout;
wrapper(function () {
- var styles = _this2.props.rtl ? _this2.getRTLMenuPosition() : _this2.getMenuPosition();
-
- _this2.subMenu.style.removeProperty('top');
- _this2.subMenu.style.removeProperty('bottom');
- _this2.subMenu.style.removeProperty('left');
- _this2.subMenu.style.removeProperty('right');
-
- if ((0, _helpers.hasOwnProp)(styles, 'top')) _this2.subMenu.style.top = styles.top;
- if ((0, _helpers.hasOwnProp)(styles, 'left')) _this2.subMenu.style.left = styles.left;
- if ((0, _helpers.hasOwnProp)(styles, 'bottom')) _this2.subMenu.style.bottom = styles.bottom;
- if ((0, _helpers.hasOwnProp)(styles, 'right')) _this2.subMenu.style.right = styles.right;
- _this2.subMenu.classList.add(_helpers.cssClasses.menuVisible);
-
- _this2.registerHandlers();
- _this2.setState({ selectedItem: null });
+ if (_this2.props.forceOpen || _this2.state.visible) {
+ _this2.subMenu.removeEventListener('transitionend', _this2.cleanup);
+ var styles = _this2.props.rtl ? _this2.getRTLMenuPosition() : _this2.getMenuPosition();
+
+ _this2.subMenu.style.removeProperty('top');
+ _this2.subMenu.style.removeProperty('bottom');
+ _this2.subMenu.style.removeProperty('left');
+ _this2.subMenu.style.removeProperty('right');
+
+ if ((0, _helpers.hasOwnProp)(styles, 'top')) _this2.subMenu.style.top = styles.top;
+ if ((0, _helpers.hasOwnProp)(styles, 'left')) _this2.subMenu.style.left = styles.left;
+ if ((0, _helpers.hasOwnProp)(styles, 'bottom')) _this2.subMenu.style.bottom = styles.bottom;
+ if ((0, _helpers.hasOwnProp)(styles, 'right')) _this2.subMenu.style.right = styles.right;
+ _this2.subMenu.classList.add(_helpers.cssClasses.menuVisible);
+
+ _this2.registerHandlers();
+ _this2.setState({ selectedItem: null });
+ }
});
} else {
2024-11-20 00:38:24 +00:00
- var cleanup = function cleanup() {
- _this2.subMenu.removeEventListener('transitionend', cleanup);
- _this2.subMenu.style.removeProperty('bottom');
- _this2.subMenu.style.removeProperty('right');
- _this2.subMenu.style.top = 0;
- _this2.subMenu.style.left = '100%';
- _this2.unregisterHandlers();
- };
- this.subMenu.addEventListener('transitionend', cleanup);
+ this.subMenu.removeEventListener('transitionend', this.cleanup);
+ this.subMenu.addEventListener('transitionend', this.cleanup);
this.subMenu.classList.remove(_helpers.cssClasses.menuVisible);
}
}