ruelluna / canvas-pointer

A Filament field that allows users to click and point markers on an image.
MIT License
19 stars 4 forks source link

[Bug]: CanvasPointerField disappears in Repeater #5

Open ast21 opened 2 months ago

ast21 commented 2 months ago

What happened?

Hi,

now I am implementing the creation of a field inside the Repeater layout, and when creating a new Repeater item, the field appears in the newly created one, and disappears in the previous items. Do you have any ideas how to implement working with the Repeater layout?

How to reproduce the bug

When I add a CanvasPointerField inside the Repeater and click AddItemButton, the CanvasPointerField in the previous Repeater item disappears

https://github.com/user-attachments/assets/f0a880d1-5fb9-4104-8ffb-e79001d7d9f4

Forms\Components\Repeater::make('body')
    ->columnSpanFull()
    ->schema([
        CanvasPointerField::make('points')
            ->pointRadius(15) // default is 5
            ->imageUrl('https://avatars.githubusercontent.com/u/97165289')
            ->width(200) // required
            ->height(200) // required
            ->label('Select body parts that are in pain')
            ->columnSpanFull(),
    ]),

Package Version

1.0.3

PHP Version

8.3

Laravel Version

11

Which operating systems does with happen with?

macOS, Windows, Linux

Notes

No response

erdalqc commented 1 month ago

We are having problems recording the marked locations to the database. Can you provide information about this issue?

HungryBus commented 1 month ago

Actually, disappears in almost all dynamic elements that are not visible when the page is loaded. Same issue with Form Steps: if CanvasPointerField is NOT in the first step that's visible on page load, it won't be visible at all

HungryBus commented 1 month ago

This is due to the Livewire updates and re-rendersthe DOM element that canvas is attached to. Please see my PR for details: https://github.com/ruelluna/canvas-pointer/pull/6