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

MultiRootEditor will trigger an additional onChange event when using @radix-ui/react-dropdown-menu #432

Open
oonxt opened this issue Nov 22, 2023 · 4 comments
Labels
pending:feedback This issue is blocked by necessary feedback.

Comments

@oonxt
Copy link

oonxt commented Nov 22, 2023

with @radix-ui/dropdown-menu:
image

All editable elements are disappeared

without:
image

here is the code

import MultiRootEditorRichDemo from "./editor";
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
import {HamburgerMenuIcon} from "@radix-ui/react-icons";
function App() {

    const multiRootEditorContent = {
        intro: '<h2>Sample</h2><p>This is an instance of the ' +
            '<a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/overview.html#classic-editor">multi-root editor build</a>.</p>',
        content: '<p>It is the custom content</p><figure class="image"></figure>',
        outro: '<p>You can use this sample to validate whether your ' +
            '<a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/development/custom-builds.html">custom build</a> works fine.</p>'
    };

    const rootsAttributes = {
        intro: {
            row: '1',
            order: 10
        },
        content: {
            row: '1',
            order: 20
        },
        outro: {
            row: '2',
            order: 10
        }
    };
    return (
        <>
            <DropdownMenu.Root>
                <DropdownMenu.Trigger asChild>
                    <button className="IconButton" aria-label="Customise options">
                        <HamburgerMenuIcon />
                    </button>
                </DropdownMenu.Trigger>
                <DropdownMenu.Portal>
                    <DropdownMenu.Content className="DropdownMenuContent" sideOffset={5}>
                        <DropdownMenu.Item className="DropdownMenuItem">
                            New Tab <div className="RightSlot">+T</div>
                        </DropdownMenu.Item>
                    </DropdownMenu.Content>
                </DropdownMenu.Portal>
            </DropdownMenu.Root>
            <MultiRootEditorRichDemo data={multiRootEditorContent} rootsAttributes={rootsAttributes}/>
        </>
    )
}

export default App
@oonxt oonxt changed the title MultiRootEditor will trigger an additional onChange event when using @radix-ui/dropdown-menu MultiRootEditor will trigger an additional onChange event when using @radix-ui/react-dropdown-menu Nov 22, 2023
@Witoso
Copy link
Member

Witoso commented Nov 27, 2023

Could you describe in details what's the problem is and the expected outcomes. It's hard to understand and judge from the screenshots. Thanks!

@Witoso Witoso added the pending:feedback This issue is blocked by necessary feedback. label Nov 27, 2023
@oonxt
Copy link
Author

oonxt commented Nov 28, 2023

ok.

The problem is this:
If we use MultiRootEditor alone, it is ok.
But if we also use @radix-ui/react-dropdown-menu at the same time, all edit boxes will disappear.

The steps to reproduce are as follows:

  1. Add a MultiRootEditorRichDemo from the sample code. https://github.com/ckeditor/ckeditor5-react/blob/master/demo-multiroot-react-18/src/MultiRootEditorRichDemo.tsx
    At this time, you will see 2 event callbacks on the console:
image

and everything goes well.

  1. import @radix-ui/react-dropdown-menu, like this:
import MultiRootEditorRichDemo from "./editor";
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
import {HamburgerMenuIcon} from "@radix-ui/react-icons";
function App() {

    const multiRootEditorContent = {
        intro: '<h2>Sample</h2><p>This is an instance of the ' +
            '<a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/overview.html#classic-editor">multi-root editor build</a>.</p>',
        content: '<p>It is the custom content</p><figure class="image"></figure>',
        outro: '<p>You can use this sample to validate whether your ' +
            '<a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/development/custom-builds.html">custom build</a> works fine.</p>'
    };

    const rootsAttributes = {
        intro: {
            row: '1',
            order: 10
        },
        content: {
            row: '1',
            order: 20
        },
        outro: {
            row: '2',
            order: 10
        }
    };
    return (
        <>
            <DropdownMenu.Root>
                <DropdownMenu.Trigger asChild>
                    <button className="IconButton" aria-label="Customise options">
                        <HamburgerMenuIcon />
                    </button>
                </DropdownMenu.Trigger>
                <DropdownMenu.Portal>
                    <DropdownMenu.Content className="DropdownMenuContent" sideOffset={5}>
                        <DropdownMenu.Item className="DropdownMenuItem">
                            New Tab <div className="RightSlot">+T</div>
                        </DropdownMenu.Item>
                    </DropdownMenu.Content>
                </DropdownMenu.Portal>
            </DropdownMenu.Root>
            <MultiRootEditorRichDemo data={multiRootEditorContent} rootsAttributes={rootsAttributes}/>
        </>
    )
}

export default App

refresh the page, at this time

  1. You will see 3 event callbacks in the console, 1 more onChange than normal.
  2. All editable boxes disappear
  3. The undo button of the toolbar will be enabled. Click undo and the disappearing edit box will appear again.
image

@Witoso
Copy link
Member

Witoso commented Nov 28, 2023

@DawidKossowski could you take a look?

@DawidKossowski
Copy link
Contributor

@oonxt, I used the code snippet you provided, but unfortunately, I cannot reproduce this issue:
Zrzut ekranu 2024-01-10 o 09 18 58

Maybe you could use an online playground to create a reproducible example and share the link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending:feedback This issue is blocked by necessary feedback.
Projects
None yet
Development

No branches or pull requests

3 participants