Issue #5156Opened May 31, 2023by loclovepop0 reactions

BUG: Cannot drag drop in mobile screen even add grapejs-touch

Question

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Chrome, IOS

Reproducible demo link

https://www.lovepoptestsite.com/products/disney-s-hocus-pocus-black-flame-candle-pop-up-card?variant=40356218077273&preview_link=124907487321 password: ilovecards

Describe the bug

How to reproduce the bug? I tried to drag and drop in mobile screen with grapejs editor alone everything is fine. But when i tried to do it after inject editor to test store it's not working as expected.

What is the expected behavior? ... It should allow drag and drop components

What is the current behavior? ... It's only grey out component and cannot drag

If is necessary to execute some code in order to reproduce the bug, paste it here below:

 const editor = grapesjs.init({
            container: editorId ? `#${editorId} #gjs` : `#editor_container #gjs`,
            height: editorHeight,
            width: editorWidth,
            avoidInlineStyle: true,
            fromElement: true,
            canvasCss: 'border-radius: 50px',
            noticeOnUnload: false,
            selectorManager: {
                componentFirst: true,
            },
            storageManager: {
                type: 'remote',
                autosave: true,
                autoload: false,
                stepsBeforeSave: 3
            },
            colorPicker: {
                appendTo: 'parent',
                offset: { top: 26, left: -166, },
            },
            panels: {
                defaults: [
                    // {
                    //     buttons: [
                    //         {
                    //             id: 'myNewButton',
                    //             className: 'fa-solid fa-eraser',
                    //             command: 'Clear',
                    //             attributes: {
                    //                 title: 'Some title',

                    //             },
                    //             active: false,
                    //         }
                    //     ]
                    // }
                ],
            },
            commands: {
                // defaults: [
                //     {
                //         id: 'Clear',
                //         async run() {
                //             await editor.load({});
                //         },
                //     }
                // ],
            },
            plugins: [plugin, grapesjsTouch],
            richTextEditor: {
                actions: ['bold', 'italic', 'underline', 'strikethrough']
            },
            styleManager: {
                appendTo: editorId ? `#${editorId} .styles-container` : '.styles-container',
                sectors: []
            },
            blockManager: {
                appendTo: editorId ? `#${editorId} #blocks` : '#blocks',
                blocks: []
            }
        });

        editor.Storage.add('remote', {
            load: handleLoad,
            store: handleStore
        });

        const updateStyleManager = (model) => {
            const typoStyleElement: any = document.querySelector('.gjs-sm-sector__typography');

            if (model.attributes.type !== 'text') {
                typoStyleElement.style.display = 'none';
            } else {
                typoStyleElement.style.display = 'block';
            }

            editor.refresh();
        }

        // Triggers on component change
        editor.on('component:selected', updateStyleManager);

        (editor.Blocks.getCategories() as any).forEach(x => {
            x.on('change:open', (e) => {
                // editor.DomComponents.clear();
                // editor.setStyle([{}])
                editor.refresh();
            })
        });

        (editor.StyleManager.getSectors() as any).forEach(x => {
            x.on('change:open', (e) => {
                editor.refresh();
            })
        });

        editor.on("load", () => {
            if (card && card.id > 0) {
                editor.load({});
            }

            const categories = editor.BlockManager.getCategories();
            (categories as any).each(category => {
                category.set('open', false).on('change:open', opened => {
                    opened.get('open') && (categories as any).each(category => {
                        category !== opened && category.set('open', false)
                    })
                })
            })
        });

        // editor.on('change:changesCount', (e) => {
        //     var count = editor.getDirtyCount();
        // });

        setEditor(editor);

Code of Conduct

  • I agree to follow this project's Code of Conduct

Answers (2)

artfJune 13, 20230 reactions

I see the touch plugin works properly, ensure to have the mobile device enabled on load (eg. not simulated post load) so the polyfill could be loaded properly.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.