Skip to content

Commit 4c2af31

Browse files
egocalrvince-fugnitto
egocalr
authored andcommitted
ensure all files present in filters
Signed-off-by: Colin Grant <[email protected]>
1 parent c837b6c commit 4c2af31

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

packages/filesystem/src/browser/file-dialog/file-dialog-tree-filters-renderer.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,24 @@ export class FileDialogTreeFilters {
3636

3737
export class FileDialogTreeFiltersRenderer extends ReactRenderer {
3838

39+
readonly appliedFilters: FileDialogTreeFilters;
40+
3941
constructor(
40-
readonly filters: FileDialogTreeFilters,
42+
readonly suppliedFilters: FileDialogTreeFilters,
4143
readonly fileDialogTree: FileDialogTree
4244
) {
4345
super();
46+
this.appliedFilters = { 'All Files': [], ...suppliedFilters, };
4447
}
4548

4649
protected readonly handleFilterChanged = (e: React.ChangeEvent<HTMLSelectElement>) => this.onFilterChanged(e);
4750

4851
protected doRender(): React.ReactNode {
49-
if (!this.filters) {
52+
if (!this.appliedFilters) {
5053
return undefined;
5154
}
5255

53-
const fileTypes = ['All Files'];
54-
Object.keys(this.filters).forEach(element => {
55-
fileTypes.push(element);
56-
});
57-
58-
const options = fileTypes.map(value => this.renderLocation(value));
56+
const options = Object.keys(this.appliedFilters).map(value => this.renderLocation(value));
5957
return <select className={'theia-select ' + FILE_TREE_FILTERS_LIST_CLASS} onChange={this.handleFilterChanged}>{...options}</select>;
6058
}
6159

@@ -67,7 +65,7 @@ export class FileDialogTreeFiltersRenderer extends ReactRenderer {
6765
const locationList = this.locationList;
6866
if (locationList) {
6967
const value = locationList.value;
70-
const filters = this.filters[value];
68+
const filters = this.appliedFilters[value];
7169
this.fileDialogTree.setFilter(filters);
7270
}
7371

0 commit comments

Comments
 (0)