1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Desktop: Fixes #2616: Expand notebook tree when clicking on notebook in search results (#2620)

This commit is contained in:
Mohammed Rabeeh 2020-03-11 19:50:25 +05:30 committed by GitHub
parent f65a3be231
commit 7e200b1ec7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -177,4 +177,19 @@ describe('models_Folder', function() {
expect(foldersById[f4.id].note_count).toBe(0);
}));
it('should recursively find folder path', asyncTest(async () => {
let f1 = await Folder.save({ title: 'folder1' });
let f2 = await Folder.save({ title: 'folder2', parent_id: f1.id });
let f3 = await Folder.save({ title: 'folder3', parent_id: f2.id });
const folders = await Folder.all();
const folderPath = await Folder.folderPath(folders, f3.id);
expect(folderPath.length).toBe(3);
expect(folderPath[0].id).toBe(f1.id);
expect(folderPath[1].id).toBe(f2.id);
expect(folderPath[2].id).toBe(f3.id);
}));
});

View File

@ -1653,6 +1653,7 @@ class NoteTextComponent extends React.Component {
folderId: this.state.folder.id,
noteId: note.id,
});
Folder.expandTree(this.props.folders, this.state.folder.parent_id);
},
});
}

View File

@ -218,6 +218,17 @@ class Folder extends BaseItem {
return output;
}
static async expandTree(folders, parentId) {
const folderPath = await this.folderPath(folders, parentId);
for (const folder of folderPath) {
this.dispatch({
type: 'FOLDER_SET_COLLAPSED',
id: folder.id,
collapsed: false,
});
}
}
static async allAsTree(folders = null, options = null) {
const all = folders ? folders : await this.all(options);