Fix: Offset upward for new posts and clear filters on pick

1. New post pin offset upward
   - Changed from {x: 0, y: 0} to {x: 0, y: -80}
   - Negative Y = moves UP on screen
   - Compensates for anchor:bottom positioning
   - Pin now appears at crosshair position

2. Clear filters when picking post from suggestions
   - When clicking a post in search results
   - Set mainFilter and subFilter to "All"
   - Ensures the post is visible
   - No more "post hidden by filters" issue

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Your Name 2025-12-23 20:27:48 -05:00
parent 366cfc0417
commit e38238d199
2 changed files with 5 additions and 3 deletions

View File

@ -234,9 +234,11 @@ export default function MapView({
essential: true
});
// If picking a post, filter by its title; otherwise clear search
// If picking a post, filter by its title AND clear category filters to ensure visibility
if (item.type === 'post' && item.title) {
setSearchQuery(item.title);
setMainFilter("All");
setSubFilter("All");
} else {
setSearchQuery("");
}

View File

@ -314,12 +314,12 @@ function calculateSmartOffset(post, markersRef, map) {
const lon = typeof post.lon === "number" ? post.lon : typeof post.lng === "number" ? post.lng : null;
if (lat == null || lon == null) return { x: 0, y: 0 };
// Si le post est très récent (< 10 secondes), pas d'offset - respect de la position crosshair
// Si le post est très récent (< 10 secondes), offset vers le HAUT pour compenser l'anchor bottom
const createdAt = post?.created_at || post?.CreatedAt || post?.createdAt;
if (createdAt) {
const ageSeconds = (Date.now() - new Date(createdAt).getTime()) / 1000;
if (ageSeconds < 10) {
return { x: 0, y: 0 };
return { x: 0, y: -80 }; // Offset vers le haut (négatif = monte)
}
}