Skip to content

Commit 72eedfb

Browse files
authored
Show file tree by default (#25052)
Feel free to close this if there isn't interest. The tree view looks amazing, and all of our users are really enjoying it (major kudos to developers!), but only IF I tell them it exists! Essentially, the file tree view as it is effectively undiscoverable. This PR changes the default state for the tree view to open, which should significantly help with discoverability. An alternative could be to reserve more horizontal space, as a typical accordion panel would look (eg. VS Code), eg. ![image](https://github.com/go-gitea/gitea/assets/12700993/505ea40c-42b1-4111-b306-48e51e8e2130)
1 parent e389714 commit 72eedfb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

templates/repo/diff/box.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
{{svg "octicon-sidebar-expand" 20 "icon gt-hidden"}}
2222
</button>
2323
<script>
24-
const diffTreeVisible = localStorage?.getItem('diff_file_tree_visible') === 'true';
24+
// Default to true if unset
25+
const diffTreeVisible = localStorage?.getItem('diff_file_tree_visible') !== 'false';
2526
const diffTreeBtn = document.querySelector('.diff-toggle-file-tree-button');
2627
const diffTreeIcon = `.octicon-sidebar-${diffTreeVisible ? 'expand' : 'collapse'}`;
2728
diffTreeBtn.querySelector(diffTreeIcon).classList.remove('gt-hidden');

web_src/js/components/DiffFileTree.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export default {
8989
}
9090
},
9191
mounted() {
92-
this.store.fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) === 'true';
92+
// Default to true if unset
93+
this.store.fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) !== 'false';
9394
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
9495
9596
this.hashChangeListener = () => {

0 commit comments

Comments
 (0)