Skip to content

Commit b3fdd00

Browse files
authored
Update fast-search-card.js
1 parent 9dcb408 commit b3fdd00

File tree

1 file changed

+128
-21
lines changed

1 file changed

+128
-21
lines changed

dist/fast-search-card.js

Lines changed: 128 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4969,15 +4969,19 @@ class FastSearchCard extends HTMLElement {
49694969

49704970
searchInput.value = '';
49714971
this.isSearching = false;
4972-
this.clearSuggestion(); // NEU HINZUFÜGEN
4972+
this.clearSuggestion();
49734973

49744974
const animation = this.animateElementOut(clearButton);
49754975
animation.finished.then(() => { clearButton.classList.remove('visible'); });
4976-
this.hasAnimated = false;
4976+
4977+
// ✅ FIX: hasAnimated NICHT hier zurücksetzen - wird in renderResults gemacht
4978+
// this.hasAnimated = false; // ← ENTFERNEN
4979+
49774980
this.showCurrentCategoryItems();
49784981
searchInput.focus();
49794982
}
49804983

4984+
49814985
toggleCategoryButtons() {
49824986
if (this.isMenuView) { this.hideCategoryButtons(); } else { this.showCategoryButtons(); }
49834987
}
@@ -5053,15 +5057,21 @@ class FastSearchCard extends HTMLElement {
50535057
selectedChip.classList.add('active');
50545058
selectedChip.animate([{ transform: 'scale(1)' }, { transform: 'scale(1.05)' }, { transform: 'scale(1)' }], { duration: 300, easing: 'cubic-bezier(0.16, 1, 0.3, 1)' });
50555059
this.activeSubcategory = subcategory;
5056-
this.hasAnimated = false;
5060+
5061+
// ✅ FIX: hasAnimated NICHT hier zurücksetzen
5062+
// this.hasAnimated = false; // ← ENTFERNEN
5063+
50575064
const searchInput = this.shadowRoot.querySelector('.search-input');
50585065
if (searchInput.value.trim()) {
50595066
searchInput.value = '';
50605067
this.isSearching = false;
50615068
const clearButton = this.shadowRoot.querySelector('.clear-button');
5062-
clearButton.classList.remove('visible');
5069+
if (clearButton.classList.contains('visible')) {
5070+
const animation = this.animateElementOut(clearButton);
5071+
animation.finished.then(() => { clearButton.classList.remove('visible'); });
5072+
}
50635073
}
5064-
this.filterBySubcategory();
5074+
this.showCurrentCategoryItems();
50655075
}
50665076

50675077
toggleFilter() {
@@ -5354,6 +5364,14 @@ class FastSearchCard extends HTMLElement {
53545364
this.showCurrentCategoryItems();
53555365
this.updateSubcategoryCounts();
53565366

5367+
// ✅ FIX: Force initial display - HIER EINFÜGEN!
5368+
setTimeout(() => {
5369+
if (this.filteredItems.length === 0) {
5370+
console.log('🔧 Force initial load');
5371+
this.showCurrentCategoryItems();
5372+
}
5373+
}, 100);
5374+
53575375
console.log(`Final items: ${this.allItems.length} (${this.allItems.filter(i => i.auto_discovered).length} auto-discovered, ${this.allItems.filter(i => i.domain === 'custom').length} custom)`);
53585376
}
53595377

@@ -6756,10 +6774,17 @@ class FastSearchCard extends HTMLElement {
67566774
return 'Custom Item';
67576775
}
67586776

6777+
67596778
performSearch(query) {
67606779
const startTime = performance.now();
67616780

6781+
// ✅ FIX: Debug-Logging hinzufügen
6782+
console.log('🔍 performSearch called with:', query);
6783+
console.log('📊 Current filteredItems before search:', this.filteredItems.length);
6784+
console.log('🏷️ activeCategory:', this.activeCategory);
6785+
67626786
if (!query.trim()) {
6787+
console.log('🔍 Empty query, showing current category items');
67636788
this.showCurrentCategoryItems();
67646789
return;
67656790
}
@@ -6768,6 +6793,7 @@ class FastSearchCard extends HTMLElement {
67686793
const preprocessedQuery = this.preprocessQuery(query);
67696794

67706795
const categoryItems = this.allItems.filter(item => this.isItemInCategory(item, this.activeCategory));
6796+
console.log('📊 categoryItems found:', categoryItems.length);
67716797

67726798
// KORREKTUR: Parse Filter-Syntax mit preprocessedQuery (nicht original query)
67736799
const parsedQuery = this.parseFilterSyntax(preprocessedQuery);
@@ -6837,11 +6863,27 @@ class FastSearchCard extends HTMLElement {
68376863
}
68386864
} else {
68396865
// FALLBACK SEARCH
6866+
console.log('🔍 Using fallback search');
68406867
this.fallbackSearch(query, categoryItems);
68416868
}
68426869

6870+
// ✅ FIX: Debug-Logging nach der Suche
6871+
console.log('📊 Search results found:', this.filteredItems.length, 'items');
6872+
console.log('🎯 About to call renderResults...');
6873+
68436874
this.logSearchPerformance(query, startTime, 'EnhancedFuzzySearch', this.filteredItems.length); // ← GEÄNDERT
68446875
this.renderResults();
6876+
6877+
// ✅ FIX: Debug nach renderResults
6878+
setTimeout(() => {
6879+
const grid = this.shadowRoot.querySelector('.results-grid');
6880+
const list = this.shadowRoot.querySelector('.results-list');
6881+
console.log('🔍 After renderResults:');
6882+
console.log(' - Grid innerHTML length:', grid?.innerHTML?.length || 0);
6883+
console.log(' - List innerHTML length:', list?.innerHTML?.length || 0);
6884+
console.log(' - hasAnimated:', this.hasAnimated);
6885+
console.log(' - Current view mode:', this.currentViewMode);
6886+
}, 50);
68456887
}
68466888

68476889
applyFilterSyntax(items, filters) {
@@ -7189,21 +7231,76 @@ class FastSearchCard extends HTMLElement {
71897231
}
71907232

71917233
showCurrentCategoryItems() {
7234+
console.log('🔍 showCurrentCategoryItems called');
7235+
console.log('📊 allItems:', this.allItems.length);
7236+
console.log('🏷️ activeCategory:', this.activeCategory);
7237+
console.log('🏷️ activeSubcategory:', this.activeSubcategory);
7238+
71927239
this.filteredItems = this.allItems.filter(item => this.isItemInCategory(item, this.activeCategory));
7193-
if (this.activeSubcategory !== 'all') { this.filterBySubcategory(); } else { this.renderResults(); }
7194-
}
7195-
7196-
isItemInCategory(item, category) {
7197-
switch (category) {
7198-
case 'devices': return !['script', 'automation', 'scene', 'custom'].includes(item.domain);
7199-
case 'scripts': return item.domain === 'script';
7200-
case 'automations': return item.domain === 'automation';
7201-
case 'scenes': return item.domain === 'scene';
7202-
case 'custom': return item.domain === 'custom';
7203-
default: return true;
7240+
7241+
console.log('📊 filteredItems after category filter:', this.filteredItems.length);
7242+
7243+
if (this.activeSubcategory !== 'all') {
7244+
this.filterBySubcategory();
7245+
} else {
7246+
this.renderResults();
72047247
}
7248+
7249+
console.log('📊 Final filteredItems:', this.filteredItems.length);
72057250
}
72067251

7252+
debugDisableAnimations() {
7253+
console.log('🚫 Disabling animations for debugging');
7254+
7255+
// Override animation functions temporarily
7256+
this.animateCardInHomeKitStyle = (card) => {
7257+
if (card) {
7258+
card.style.opacity = '1';
7259+
card.style.transform = 'none';
7260+
card.style.filter = 'none';
7261+
}
7262+
};
7263+
7264+
this.animateHeaderIn = (header) => {
7265+
if (header) {
7266+
header.style.opacity = '1';
7267+
header.style.transform = 'none';
7268+
}
7269+
};
7270+
7271+
this.animateElementIn = (element) => {
7272+
if (element) {
7273+
element.style.opacity = '1';
7274+
element.style.transform = 'none';
7275+
}
7276+
};
7277+
}
7278+
7279+
forceRenderResults() {
7280+
console.log('🔧 Force rendering results');
7281+
7282+
// Force reset
7283+
this.hasAnimated = false;
7284+
this.animationTimeouts = [];
7285+
7286+
// Force all items visible
7287+
const cards = this.shadowRoot.querySelectorAll('.device-card');
7288+
const headers = this.shadowRoot.querySelectorAll('.area-header');
7289+
7290+
cards.forEach(card => {
7291+
card.style.opacity = '1';
7292+
card.style.transform = 'none';
7293+
card.style.filter = 'none';
7294+
});
7295+
7296+
headers.forEach(header => {
7297+
header.style.opacity = '1';
7298+
header.style.transform = 'none';
7299+
});
7300+
7301+
console.log('✅ Force render completed');
7302+
}
7303+
72077304
filterBySubcategory() {
72087305
if (this.activeSubcategory === 'all') {
72097306
this.showCurrentCategoryItems();
@@ -7243,6 +7340,7 @@ class FastSearchCard extends HTMLElement {
72437340
this.renderResults();
72447341
}
72457342

7343+
72467344
renderResults() {
72477345
const resultsGrid = this.shadowRoot.querySelector('.results-grid');
72487346
const resultsList = this.shadowRoot.querySelector('.results-list');
@@ -7251,12 +7349,22 @@ class FastSearchCard extends HTMLElement {
72517349
this.animationTimeouts.forEach(timeout => clearTimeout(timeout));
72527350
this.animationTimeouts = [];
72537351

7254-
// Hide both containers initially
7352+
// ✅ FIX: hasAnimated bei jeder neuen Suche zurücksetzen
7353+
this.hasAnimated = false;
7354+
7355+
// Show/Hide containers
72557356
resultsGrid.style.display = this.currentViewMode === 'grid' ? 'grid' : 'none';
72567357
resultsList.classList.toggle('active', this.currentViewMode === 'list');
72577358

7359+
// Check for empty results
72587360
if (this.filteredItems.length === 0) {
7259-
const emptyState = `<div class="empty-state"><div class="empty-icon">🔍</div><div class="empty-title">Keine Ergebnisse</div><div class="empty-subtitle">Versuchen Sie einen anderen Suchbegriff</div></div>`;
7361+
const emptyState = `
7362+
<div class="empty-state">
7363+
<div class="empty-icon">🔍</div>
7364+
<div class="empty-title">Keine Ergebnisse</div>
7365+
<div class="empty-subtitle">Versuchen Sie einen anderen Suchbegriff</div>
7366+
</div>`;
7367+
72607368
if (this.currentViewMode === 'grid') {
72617369
resultsGrid.innerHTML = emptyState;
72627370
} else {
@@ -7265,12 +7373,11 @@ class FastSearchCard extends HTMLElement {
72657373
return;
72667374
}
72677375

7268-
// 🌟 NEU: Stars sammeln
7376+
// Get starred items
72697377
const starredItems = this.getUserStarredItems();
7270-
7271-
// Alle Items für Raum-Sektionen (inkl. Stars)
72727378
const nonStarredItems = this.filteredItems;
72737379

7380+
// Render based on view mode
72747381
if (this.currentViewMode === 'grid') {
72757382
this.renderGridResults(resultsGrid, starredItems, nonStarredItems);
72767383
} else {

0 commit comments

Comments
 (0)