🚸 Make app grid popup menu toggle visibility when clicking on it (#325) (#448)

* 🚸 Make app grid popup menu toggle visibility when clicking on it (#325)
This commit is contained in:
ericlinagora
2024-03-15 16:50:11 +01:00
committed by GitHub
parent 47daa53705
commit 728dd3092b
4 changed files with 23 additions and 19 deletions
+8 -4
View File
@@ -3,16 +3,20 @@
## Features ## Features
- New Version Semantics - New Version Semantics
- Usage quota settings - Usage quota settings
- PostgreSQL support as a metadata database - PostgreSQL support as a metadata database
- OpenSearch support as a search database - OpenSearch support as a search database
- New API to check file storage consistency - New API to check file storage consistency
- UX improvements - UX improvements
- Remove the switcher from breadcrumbs - Remove the switcher from breadcrumbs
- Improved translations
- Be able to use SMTP transport without TLS
- Do not display deleted items in the shared with me section
## BugFixes ## BugFixes
- Fix preview of the files on mobile and web - Fix preview of the files on mobile and web
- Malformed URL when you share a file - Malformed URL when you share a file
- ...
# Twake Drive v2023.Q3.012 # Twake Drive v2023.Q3.012
@@ -22,10 +22,6 @@ export default class Menu extends React.Component {
} }
*/ */
static closeAll() {
MenusManager.closeAllMenus(); // Corrected method name to closeAllMenus()
}
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@@ -51,21 +47,24 @@ export default class Menu extends React.Component {
MenusManager.openMenu(menu, rect, position); MenusManager.openMenu(menu, rect, position);
} }
openMenu(evt) { async openMenu(evt) {
if (this.open) { if (this.open) {
this.closeAll(); this.open = false;
MenusManager.closeMenu();
this.setState({ isMenuOpen: false });
} else { } else {
this.open = true;
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
var elementRect = this.container.current.getBoundingClientRect(); // Fixed getBoundingClientRect() var elementRect = this.container.current.getBoundingClientRect(); // Fixed getBoundingClientRect()
elementRect.x = elementRect.x || elementRect.left; elementRect.x = elementRect.x || elementRect.left;
elementRect.y = elementRect.y || elementRect.top; elementRect.y = elementRect.y || elementRect.top;
this.previousMenusId = MenusManager.openMenu( // Updated variable name this.previousMenusId = await MenusManager.openMenu(
this.props.menu, this.props.menu,
elementRect, elementRect,
this.props.position, this.props.position,
); );
this.setState({ isMenuOpen: true }, () => this.open = true);
this.open = true;
if (this.props.onOpen) this.props.onOpen(); if (this.props.onOpen) this.props.onOpen();
} }
} }
@@ -77,7 +76,7 @@ export default class Menu extends React.Component {
if ( if (
(MenusManager.menus.length === 0 && this.previousMenusNumber > 0) || (MenusManager.menus.length === 0 && this.previousMenusNumber > 0) ||
MenusManager.lastOpenedId !== this.previousMenusId // Updated variable name MenusManager.last_opened_id !== this.previousMenusId
) { ) {
if (this.open && this.props.onClose) { if (this.open && this.props.onClose) {
this.props.onClose(); this.props.onClose();
@@ -103,18 +102,18 @@ export default class Menu extends React.Component {
<div <div
ref={this.container} ref={this.container}
style={this.props.style} style={this.props.style}
onClick={(evt) => { onClick={async (evt) => {
console.log('if this open: ', this.state.isMenuOpen);
if (this.props.toggle) { if (this.props.toggle) {
if (!this.open) { if (!this.open) {
this.setState({ ...this.state, isMenuOpen: true }); await this.openMenu(evt);
this.openMenu(evt);
} else { } else {
MenusManager.closeMenu(); MenusManager.closeMenu();
this.open = false;
this.setState({ isMenuOpen: false });
this.props.onClose && this.props.onClose(); this.props.onClose && this.props.onClose();
} }
} else { } else {
this.openMenu(evt); await this.openMenu(evt);
} }
}} }}
className={this.props.className} className={this.props.className}
@@ -2,4 +2,4 @@ export default {
version: /* @VERSION */ '1.0.1', version: /* @VERSION */ '1.0.1',
version_detail: /* @VERSION_DETAIL */ '1.0.1', version_detail: /* @VERSION_DETAIL */ '1.0.1',
version_name: /* @VERSION_NAME */ 'Ghost-Dog', version_name: /* @VERSION_NAME */ 'Ghost-Dog',
}; };
@@ -14,6 +14,7 @@ export default ({ className }: { className?: string }): JSX.Element => {
return ( return (
<Menu <Menu
position="bottom" position="bottom"
toggle="true"
menu={[ menu={[
{ {
type: 'react-element', type: 'react-element',