plate icon indicating copy to clipboard operation
plate copied to clipboard

Toolbar buttons have unexpected behaviour when there are multiple plate instance in one page

Open InfiniteXyy opened this issue 3 years ago • 0 comments

Description When there are two instance in one page, destroy the second one when it's focused will cause the toolbar of the first one to hide. Before(2 plates): image After hide the second one (the icons will be hidden): image

Steps

  1. Go to codesandbox page
  2. Focus the second plate editor
  3. click "toggle second editor"
  4. you'll see the icon for the first button is hidden.

Sandbox

https://codesandbox.io/s/eager-thompson-czn5oe?file=/src/index.tsx

Expectation

  1. Toolbars should only control the editor it is bind to.
  2. Toolbars of "plate A" should not be hidden when "plate B" instance is destroyed.

Environment

  • slate: 0.78.0
  • slate-react: 0.79.0
  • browser: chrome

Possible Cause I have read some of the source code, and have found all tool icons are controller by this plateProvider, and when the active plate is not inside vdom, it will return null. Maybe it's the cause. https://github.com/udecode/plate/blob/de1fe1a183e6154971f6f18fcdd413dbfb10239e/packages/core/src/components/plate/PlateProvider.tsx#L17-L22

thank you for helping me investigating this issue!

InfiniteXyy avatar Aug 29 '22 06:08 InfiniteXyy