1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 01:41:39 +00:00

file chooser bug repair (#2839)

This commit is contained in:
杨顺强
2019-01-17 10:37:40 +08:00
committed by Daniel Pan
parent ca4dee899b
commit aeff5144dd

View File

@@ -29,17 +29,19 @@ class DirentListItem extends React.Component {
}; };
} }
onItemClick = () => { onItemClick = (e) => {
e.stopPropagation(); // need prevent event popup
if (this.props.selectedPath !== this.state.filePath) { if (this.props.selectedPath !== this.state.filePath) {
this.props.onDirentItemClick(this.state.filePath, this.props.dirent); this.props.onDirentItemClick(this.state.filePath, this.props.dirent);
} else { } else {
if (this.props.dirent.type === 'dir') { if (this.props.dirent.type === 'dir') {
this.onToggleClick(); this.onToggleClick(e);
} }
} }
} }
onToggleClick = () => { onToggleClick = (e) => {
e.stopPropagation(); // need prevent event popup
if (!this.state.hasRequest) { if (!this.state.hasRequest) {
seafileAPI.listDir(this.props.repo.repo_id, this.state.filePath).then(res => { seafileAPI.listDir(this.props.repo.repo_id, this.state.filePath).then(res => {
let direntList = []; let direntList = [];
@@ -53,18 +55,14 @@ class DirentListItem extends React.Component {
direntList.push(dirent); direntList.push(dirent);
} }
} }
direntList = Utils.sortDirents(direntList, 'name', 'asc'); });
this.setState({ direntList = Utils.sortDirents(direntList, 'name', 'asc');
hasRequest: true, this.setState({
direntList: direntList, hasRequest: true,
}); direntList: direntList,
}); });
if (res.data.length === 0 || direntList.length === 0) { if (res.data.length === 0 || direntList.length === 0) {
this.setState({ this.setState({hasChildren: false});
hasRequest: true,
direntList: [],
hasChildren: false
});
} }
}); });
} }