Skip to content

Commit bad7129

Browse files
Merge pull request #86 from Arpitawork24/main
Fix unresponsive UI caused by null DOM references (#76)
2 parents 09d2796 + 77e19dd commit bad7129

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

web-app/css/styles.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ body {
921921
bottom: 1rem;
922922
width: 3rem;
923923
height: 3rem;
924+
}
924925

925926
.search-wrapper {
926927
max-width: 100%;
@@ -1072,4 +1073,4 @@ body {
10721073
.modal-close:hover {
10731074
transform: none;
10741075
}
1075-
}
1076+
}

web-app/js/main.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const themeToggle = document.getElementById('themeToggle');
33
const themeColorMeta = document.getElementById('themeColorMeta');
44
const html = document.documentElement;
55
const mainContent = document.getElementById('main-content');
6+
let recentSearches = [];
67

78
function prefersReducedMotion() {
89
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -61,7 +62,7 @@ backToTopButton.addEventListener('click', () => {
6162
});
6263

6364
// Category Filtering
64-
const tabs = document.querySelectorAll('.tab');
65+
// const tabs = document.querySelectorAll('.tab');
6566

6667
// Category Filtering (tabs)
6768

@@ -171,14 +172,21 @@ function highlightMatch(text, query) {
171172

172173
// Render recent searches
173174
function renderRecentSearches() {
174-
if (recentSearches.length === 0) {
175-
recentSearchesSection.style.display = 'none';
176-
tipsSection.style.display = 'block';
177-
resultsSection.style.display = 'none';
178-
return;
175+
if (recentSearchesSection) {
176+
recentSearchesSection.style.display = 'none';
177+
}
178+
179+
if (tipsSection) {
180+
tipsSection.style.display = 'block';
181+
}
182+
183+
if (resultsSection) {
184+
resultsSection.style.display = 'none';
179185
}
180186

187+
if (recentSearchesList) {
181188
recentSearchesList.innerHTML = '';
189+
}
182190
recentSearches.slice(0, 5).forEach((search) => {
183191
const item = document.createElement('div');
184192
item.className = 'dropdown-recent-item';
@@ -212,11 +220,15 @@ function renderRecentSearches() {
212220
recentSearchesList.appendChild(item);
213221
});
214222

223+
if (recentSearchesSection && resultsSection && tipsSection) {
215224
recentSearchesSection.style.display = 'block';
216225
resultsSection.style.display = 'none';
217226
tipsSection.style.display = 'block';
218227
}
219228

229+
230+
}
231+
220232
function applyCategoryFilter(category) {
221233
projectCards.forEach((card) => {
222234
if (category === 'all' || card.getAttribute('data-category') === category) {

0 commit comments

Comments
 (0)