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:
parent
366cfc0417
commit
e38238d199
|
|
@ -234,9 +234,11 @@ export default function MapView({
|
||||||
essential: true
|
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) {
|
if (item.type === 'post' && item.title) {
|
||||||
setSearchQuery(item.title);
|
setSearchQuery(item.title);
|
||||||
|
setMainFilter("All");
|
||||||
|
setSubFilter("All");
|
||||||
} else {
|
} else {
|
||||||
setSearchQuery("");
|
setSearchQuery("");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -314,12 +314,12 @@ function calculateSmartOffset(post, markersRef, map) {
|
||||||
const lon = typeof post.lon === "number" ? post.lon : typeof post.lng === "number" ? post.lng : null;
|
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 };
|
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;
|
const createdAt = post?.created_at || post?.CreatedAt || post?.createdAt;
|
||||||
if (createdAt) {
|
if (createdAt) {
|
||||||
const ageSeconds = (Date.now() - new Date(createdAt).getTime()) / 1000;
|
const ageSeconds = (Date.now() - new Date(createdAt).getTime()) / 1000;
|
||||||
if (ageSeconds < 10) {
|
if (ageSeconds < 10) {
|
||||||
return { x: 0, y: 0 };
|
return { x: 0, y: -80 }; // Offset vers le haut (négatif = monte)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue