Fixes keys for new react version (#948)

* Fix for new react version

* Fix CustomCSS editor.

* Fix Dropdown Menus.

* Update drodown.jsx

* Remove unused variable

Fixes #949
Fixes #950
This commit is contained in:
Strencher 2021-07-26 00:08:17 +02:00 committed by GitHub
parent 65dc214ffe
commit 87efffb7e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -67,7 +67,7 @@ export default new class CustomCSS extends Builtin {
if (this.isDetached) return;
if (this.nativeOpen) return this.openNative();
else if (this.startDetached) return this.openDetached(this.savedCss);
const settingsView = Utilities.findInRenderTree(thisObject._reactInternalFiber, m => m && m.onSetSection, {walkable: ["child", "memoizedProps", "props", "children"]});
const settingsView = Utilities.findInRenderTree(thisObject._reactInternals, m => m && m.onSetSection, {walkable: ["child", "memoizedProps", "props", "children"]});
if (settingsView && settingsView.onSetSection) settingsView.onSetSection(this.id);
}
});

View File

@ -278,7 +278,7 @@ export default class Utilities {
static getReactInstance(node) {
if (node.__reactInternalInstance$) return node.__reactInternalInstance$;
return node[Object.keys(node).find(k => k.startsWith("__reactInternalInstance"))] || null;
return node[Object.keys(node).find(k => k.startsWith("__reactInternalInstance") || k.startsWith("__reactFiber"))] || null;
}
/**

View File

@ -13,7 +13,11 @@ export default class Select extends React.Component {
showMenu(event) {
event.preventDefault();
this.setState({open: true}, () => {
event.stopPropagation();
this.setState((state) => ({open: !state.open}), () => {
if (!this.state.open) return;
document.addEventListener("click", this.hideMenu);
});
}