Fix: Auto-adjust filters on search and fix post pin position
1. Auto-clear category filters when searching - When user searches, set mainFilter and subFilter to "All" - Ensures search results are visible regardless of category - No more hidden results due to filter mismatch 2. Fix post pin offset after creation - New posts (< 10 seconds old) have NO smart offset - Respects crosshair position chosen by user - Pin appears exactly where user aimed - Older posts still get smart offset to avoid overlaps 🤖 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
964a133f5b
commit
366cfc0417
|
|
@ -245,6 +245,12 @@ export default function MapView({
|
|||
const handleSearch = (query) => {
|
||||
console.log('[MapView] Search/filter by:', query);
|
||||
setSearchQuery(query);
|
||||
|
||||
// Clear category filters to show all search results
|
||||
if (query.trim()) {
|
||||
setMainFilter("All");
|
||||
setSubFilter("All");
|
||||
}
|
||||
};
|
||||
|
||||
// Zoom intelligent: quand on cherche, zoom pour voir tous les résultats
|
||||
|
|
|
|||
|
|
@ -314,6 +314,15 @@ 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
|
||||
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 };
|
||||
}
|
||||
}
|
||||
|
||||
const currentPoint = map.project([lon, lat]);
|
||||
const PROXIMITY_THRESHOLD = 100; // pixels - larger to detect more overlaps
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue