fix(map): selectFeature event handling - unify payload format for map click and feature table
- FeatureTable: dispatch { featureId } object instead of raw ID
- ProjectMap: selectFeature listener accepts both formats (direct ID or { featureId })
- project-map.blade.php: move selectFeature inside livewire:init handler so Livewire.emit is available
- Added logging for debugging
Fixes: 'Livewire.emit is not a function' on map click and 'Only arrays and Traversables can be unpacked' on table button
This commit is contained in:
@@ -228,6 +228,13 @@ class ProjectMap extends Component
|
||||
#[On('map-select-feature')]
|
||||
public function selectFeature($featureId)
|
||||
{
|
||||
\Log::info('map-select-feature received', ['payload' => $featureId]);
|
||||
|
||||
// Handle both formats: direct ID or { featureId: X }
|
||||
if (is_array($featureId) && isset($featureId['featureId'])) {
|
||||
$featureId = $featureId['featureId'];
|
||||
}
|
||||
|
||||
$this->selectedFeature = null;
|
||||
$feature = Feature::with(['template', 'layer.phase'])->find($featureId);
|
||||
if (!$feature) return;
|
||||
|
||||
Reference in New Issue
Block a user