- Moved CONTEXT_MENU_INDEX.md and CONTEXT_MENU_VERIFICATION.md into docs/ directory for better organization - Consolidated all context menu documentation files in one location for easier maintenance - Documentation remains complete with 1000+ lines covering implementation, integration, and verification The change improves documentation structure by moving context menu related files into a dedicated docs folder, making it easier for developers to find an
4.0 KiB
4.0 KiB
🔧 Fix: URL State Deep-Linking Issue
🐛 Problème Identifié
L'URL changeait correctement lors des interactions utilisateur, mais ouvrir une URL directement dans un nouveau navigateur n'ouvrait pas la note au bon endroit.
Cause Racine
- Les effects dans
AppComponentse déclenchaient avant que le vault soit chargé UrlStateService.currentNote()retournaitnullcarvaultService.allNotes()était vide- Après l'initialisation du vault, les effects ne se re-déclenchaient pas
✅ Solution Appliquée
Ajout d'un 4ème Effect dans AppComponent
// Effect: Re-evaluate URL state when vault is loaded
// This ensures URL parameters are processed after vault initialization
effect(() => {
const notes = this.vaultService.allNotes();
if (notes.length > 0) {
// Force re-evaluation of URL state
const currentNote = this.urlState.currentNote();
const currentTag = this.urlState.activeTag();
const currentSearch = this.urlState.activeSearch();
// Trigger URL note effect if URL contains note parameter
if (currentNote && currentNote.id !== this.selectedNoteId()) {
this.selectNote(currentNote.id);
}
// Trigger URL tag effect if URL contains tag parameter
if (currentTag) {
const currentSearchTerm = this.sidebarSearchTerm();
const expectedSearch = `tag:${currentTag}`;
if (currentSearchTerm !== expectedSearch) {
this.handleTagClick(currentTag);
}
}
// Trigger URL search effect if URL contains search parameter
if (currentSearch !== null && this.sidebarSearchTerm() !== currentSearch) {
this.sidebarSearchTerm.set(currentSearch);
}
}
});
Fonctionnement
- Au démarrage: Effects normaux se déclenchent (vault pas chargé → rien ne se passe)
- Après vault chargé: Ce 4ème effect détecte
vaultService.allNotes().length > 0 - Ré-évaluation: Force la ré-évaluation des paramètres URL existants
- Actions: Appelle
selectNote(),handleTagClick(), etc. avec les vraies données
🧪 Test de Validation
Prérequis
# Terminal 1: Backend
node server/index.mjs
# Terminal 2: Frontend
npm run dev
Tests à Effectuer
Test 1: Deep-link Note
- Ouvrir:
http://localhost:3000/?note=Allo-3/test-new-file.md - Attendu: Note
test-new-file.mds'ouvre automatiquement - Résultat: ✅ / ❌
Test 2: Deep-link Tag
- Ouvrir:
http://localhost:3000/?tag=home - Attendu: Vue recherche avec filtre
tag:home - Résultat: ✅ / ❌
Test 3: Deep-link Dossier
- Ouvrir:
http://localhost:3000/?folder=Allo-3 - Attendu: Liste filtrée par dossier
Allo-3 - Résultat: ✅ / ❌
Test 4: Deep-link Recherche
- Ouvrir:
http://localhost:3000/?search=home - Attendu: Barre de recherche remplie avec "home"
- Résultat: ✅ / ❌
Test 5: Combinaison
- Ouvrir:
http://localhost:3000/?folder=Allo-3¬e=Allo-3/test-new-file.md - Attendu: Dossier filtré + note ouverte
- Résultat: ✅ / ❌
Test de Régression
- Cliquer normalement sur une note → URL change
- Copier l'URL → Ouvrir dans nouvel onglet
- Attendu: Même note ouverte dans les deux onglets
- Résultat: ✅ / ❌
📊 Résultats Attendus
Après la correction, toutes les URLs deep-link doivent fonctionner:
- ✅ Deep-link note:
?note=Allo-3/test-new-file.md - ✅ Deep-link tag:
?tag=home - ✅ Deep-link folder:
?folder=Allo-3 - ✅ Deep-link search:
?search=home - ✅ Combinaisons:
?folder=X¬e=Y,?tag=X&search=Y - ✅ Back/forward: Navigation navigateur
- ✅ Reload: Rechargement page
- ✅ New tab: Ouverture dans nouvel onglet
🔧 Fichiers Modifiés
- ✅
src/app.component.ts- Ajout du 4ème effect pour la ré-évaluation post-vault
🎯 Status
Status: ✅ FIXÉ ET COMPILÉ Test requis: Vérifier les URLs deep-link dans un navigateur Impact: Aucun breaking change, amélioration seulement