diff --git a/frontend/src/components/main-side-nav-folded.js b/frontend/src/components/main-side-nav-folded.js
index a6892a4a16..908983ae30 100644
--- a/frontend/src/components/main-side-nav-folded.js
+++ b/frontend/src/components/main-side-nav-folded.js
@@ -41,24 +41,33 @@ class MainSideNavFolded extends React.Component {
handleOutsideClick = (e) => {
const { isFilesSubNavShown } = this.state;
if (isFilesSubNavShown && !this.filesSubNav.contains(e.target)) {
- this.toggleSubNav();
+ this.closeSubNav();
}
};
- toggleSubNav = () => {
- this.setState({
- isFilesSubNavShown: !this.state.isFilesSubNavShown
- }, () => {
- if (this.state.isFilesSubNavShown) {
- this.loadGroups();
- }
+ openSubNav = () => {
+ if (this.state.isFilesSubNavShown) return;
+ seafileAPI.listGroups().then(res => {
+ this.canCloseNav = false;
+ this.setState({
+ groupItems: res.data.map(item => new Group(item)).sort((a, b) => a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1),
+ isFilesSubNavShown: true
+ }, () => {
+ setTimeout(() => {
+ this.canCloseNav = true;
+ }, 500);
+ });
+ }).catch(error => {
+ let errMessage = Utils.getErrorMsg(error);
+ toaster.danger(errMessage);
});
};
- filesOnMouseOver = () => {
- if (!this.state.isFilesSubNavShown) {
- this.toggleSubNav();
- }
+ closeSubNav = () => {
+ if (!this.state.isFilesSubNavShown || !this.canCloseNav) return;
+ this.setState({
+ isFilesSubNavShown: false
+ });
};
tabItemClick = (e, param, id) => {
@@ -72,17 +81,6 @@ class MainSideNavFolded extends React.Component {
window.uploader.isUploadProgressDialogShow = false;
}
this.props.tabItemClick(param, id);
-
- /*
- if (this.props.currentTab == 'libraries' && param == 'libraries') {
- e.stopPropagation();
- this.toggleSubNav();
- } else {
- this.setState({
- isFilesSubNavShown: false
- });
- }
- */
this.setState({
isFilesSubNavShown: false
});
@@ -92,24 +90,6 @@ class MainSideNavFolded extends React.Component {
return this.props.currentTab === tab ? 'active' : '';
};
- loadGroups = () => {
- seafileAPI.listGroups().then(res => {
- let groupList = res.data.map(item => {
- let group = new Group(item);
- return group;
- });
-
- this.setState({
- groupItems: groupList.sort((a, b) => {
- return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
- })
- });
- }).catch(error => {
- let errMessage = Utils.getErrorMsg(error);
- toaster.danger(errMessage);
- });
- };
-
render() {
let showActivity = isDocs || isPro || !isDBSqlite3;
const { groupItems, isFilesSubNavShown } = this.state;
@@ -123,20 +103,20 @@ class MainSideNavFolded extends React.Component {
to={ siteRoot + 'libraries/' }
className={`nav-link ellipsis ${this.getActiveClass('libraries')}`}
onClick={(e) => this.tabItemClick(e, 'libraries')}
- onMouseOver={this.filesOnMouseOver}
+ onMouseOver={this.openSubNav}
>
-
-