Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Custom?] elements nested within table cells are not rendered beyond initial value #4066

Open
chrisui opened this issue Feb 10, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@chrisui
Copy link

chrisui commented Feb 10, 2025

Description

Originally posted issue in discord here: https://discord.com/channels/1026227597115396188/1026256206915965078/1336745607993495613

When calling editor.tf.setValue() with a value which has table cells containing custom elements the custom elements are not rendered - only one element within a cell is rendered.

This is demonstrated in the repro link provided.

The use case is simply instantiating the editor with an empty value, loading data from the server and using tf.setValue to display the value fetched from the server.

Example

Using the following value, when it is provided as an initial value for the editor, you will see rendered the "ref" element with text "im a custom element, nested within a table, and will vanish after later editor.tf.setValue updates" however if you then call edtor.tf.setValue([mockTableValue]) you will see the table rendered but without that element rendered or text visible.

const mockTableValue = {
  children: [
    {
      children: [
        {
          children: [
            {
              children: [
                {
                  text: 'Rule',
                },
              ],
              type: 'p',
            },
          ],
          type: 'th',
        },
      ],
      type: 'tr',
    },
    {
      children: [
        {
          children: [
            {
              children: [
                {
                  text: 'Some text in a paragraph. ',
                },
              ],
              type: 'p',
            },
            {
              type: 'ref',
              identifier: 'reference_1',
              label: 'reference_1',
              children: [
                {
                  text: 'im a custom element, nested within a table, and will vanish after later editor.tf.setValue updates',
                },
              ],
              url: '',
              title: 'test title',
            },
          ],
          type: 'td',
        },
      ],
      type: 'tr',
    },
  ],
  type: 'table',
};

Reproduction URL

https://codesandbox.io/p/github/chrisui/plate-table-issues-repro/main?import=true

Reproduction steps

1. Load preview https://4wf96c-3000.csb.app/editor
2. Note how the blue custom element will disappear after 1000ms when a `tf.setValue(clonedInitialValue)` is called to demonstrate the issue

Plate version

v43 as per latest template (but also validated in v41)

Slate React version

0.112.0

Screenshots

initial value:

Image

after using setValue with the exact same initial value:

(note absence of custom element)

Image

Logs

Browsers

Chrome

@chrisui chrisui added the bug Something isn't working label Feb 10, 2025
@chrisui chrisui changed the title Custom elements nested within table cells are not rendered beyond initial value [Custom?] elements nested within table cells are not rendered beyond initial value Feb 10, 2025
@chrisui
Copy link
Author

chrisui commented Feb 10, 2025

Note there is a console error Cannot update a component (ForwardRef) while rendering a different component (ForwardRef). however this is most likely just a coincidental error as I do not get this with my local non-minimal repro (older version plate v41) but still get the same bug behaviour.

@chrisui
Copy link
Author

chrisui commented Feb 11, 2025

update (no progress on finding issue source): https://discord.com/channels/1026227597115396188/1338524246426517524/1338838100369215539

@chrisui
Copy link
Author

chrisui commented Feb 19, 2025

Note possible related issue within plate-markdown deserialiser: https://discord.com/channels/1026227597115396188/1026256206915965078/1341472556326064229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant