Right now in the canvas we have implemented a single selection mechanism.
If you click on a given shape it will just surround the sape with a trasnformer, if you click on another shape, selection will swap to that given shape, but we need a mechanism to clear the selection whenever you click on the canvas
Some like:
On the canvas Stage component hook to the onMouseDown and onTouchStart (mobile and tablet) events.
When this events are fired clean the selection arrays setShapes([])
<div style={{ border: "1px solid black" }}>
{/*TODO: right now harcoded values, remove this once we have final layout*/}
<Stage width={1024} height={800}
+ onMouseDown={handleClearSelection}
+ onTouchStart={handleClearSelection}
>
<Layer>
Once you have implemented this, just apply a refactor, enclose the handleClearSelection in the useSelection hook
Right now in the canvas we have implemented a single selection mechanism.
If you click on a given shape it will just surround the sape with a trasnformer, if you click on another shape, selection will swap to that given shape, but we need a mechanism to clear the selection whenever you click on the canvas
Some like:
Stage
component hook to theonMouseDown
andonTouchStart
(mobile and tablet) events.setShapes([])
Sample code (psuedocode)
./src/canvas.pods.tsx
And on the handlers:
Once you have implemented this, just apply a refactor, enclose the
handleClearSelection
in the useSelection hookMore background about the issue:
https://codesandbox.io/s/github/konvajs/site/tree/master/react-demos/transformer?from-embed=&file=/src/index.js:2323-2522