Skip to content

Commit 761314a

Browse files
committed
fix: hide snippet header when no snippets are present
1 parent 83b1a6c commit 761314a

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/extensionsIntegrated/CustomSnippets/src/UIHelper.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,30 @@ define(function (require, exports, module) {
112112
}
113113
}
114114

115+
/**
116+
* Shows the snippets list header
117+
* this is called when there are snippets to display
118+
*/
119+
function showSnippetsListHeader() {
120+
const $snippetsListHeader = $("#snippets-list-header");
121+
$snippetsListHeader.removeClass("hidden");
122+
}
123+
124+
/**
125+
* Hides the snippets list header
126+
* this is called when there are no snippets to display (either none exist or all filtered out)
127+
*/
128+
function hideSnippetsListHeader() {
129+
const $snippetsListHeader = $("#snippets-list-header");
130+
$snippetsListHeader.addClass("hidden");
131+
}
132+
115133
exports.showEmptySnippetMessage = showEmptySnippetMessage;
116134
exports.showSnippetsList = showSnippetsList;
117135
exports.clearSnippetsList = clearSnippetsList;
118136
exports.showAddSnippetMenu = showAddSnippetMenu;
119137
exports.showSnippetListMenu = showSnippetListMenu;
120138
exports.showDuplicateAbbreviationError = showDuplicateAbbreviationError;
139+
exports.showSnippetsListHeader = showSnippetsListHeader;
140+
exports.hideSnippetsListHeader = hideSnippetsListHeader;
121141
});

src/extensionsIntegrated/CustomSnippets/src/snippetsList.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ define(function (require, exports, module) {
6868
*/
6969
function _showEmptyState() {
7070
UIHelper.showEmptySnippetMessage();
71+
UIHelper.hideSnippetsListHeader();
7172
const $emptyMessage = $("#no-snippets-message");
7273
const $filterInput = $("#filter-snippets-input");
7374
const filterText = $filterInput.val().trim();
@@ -86,6 +87,7 @@ define(function (require, exports, module) {
8687
*/
8788
function _renderSnippetsList(filteredSnippets) {
8889
UIHelper.showSnippetsList(); // show the snippets list wrapper
90+
UIHelper.showSnippetsListHeader(); // show header when there are snippets to display
8991

9092
// add each filtered snippet to the list
9193
filteredSnippets.forEach(function(snippetItem) {

src/styles/Extn-CustomSnippets.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@
132132
display: none;
133133
}
134134

135+
#snippets-list-header.hidden {
136+
display: none;
137+
}
138+
135139
#custom-snippets-panel .resizable-content {
136140
overflow-y: scroll;
137141
overflow-x: auto;

0 commit comments

Comments
 (0)