-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Gridstack in WordPress editor (Gutenberg) mobile preview iframe not working. #2670
Comments
This comment by @damien-schneider seems promising: |
Yes I'll try to work on it as soon as I have free time. |
When changing to tablet/mobile view, the items lose the drop ability, and the resize is weird ... Screen.Recording.2024-04-30.at.12.32.18.mov |
that error static getElement(els: GridStackElement, root: HTMLElement | Document = document): HTMLElement {
if (typeof els === 'string') {
const doc = ('getElementById' in root) ? root as Document : undefined;
if (!els.length) return null;
if (doc && els[0] === '#') {
return doc.getElementById(els.substring(1));
}
if (els[0] === '#' || els[0] === '.' || els[0] === '[') {
return root.querySelector(els);
}
// if we start with a digit, assume it's an id (error calling querySelector('#1')) as class are not valid CSS
if (doc && !isNaN(+els[0])) { // start with digit
return doc.getElementById(els);
}
// finally try string, then id, then class
let el = root.querySelector(els);
if (doc && !el) { el = doc.getElementById(els) }
if (!el) { el = root.querySelector('.' + els) }
return el as HTMLElement;
}
return els;
} |
Thanks, @adumesny , for taking time to reply. I am aware that Gridstack cannot find the selector needed to initialize. This issue is AFAIK related to React and WordPress editor specifics. Like I said, @damien-schneider was on the right track with their solution in the #2002 comment ... |
Subject of the issue
I am trying to implement Gridstack.js in WP editor plugin, and there's an issue with WP editor's screen when in mobile preview,
The Gridstack fails to initialize with message in console:
The issue seem to be related to iframe in which the preview is loaded (only for mobile preview). The desktop preview works fine.
I am not sure if this issue is lib or Gutenberg related ...
I am using the exact same Gridstack code provided in the React demo: https://github.com/gridstack/gridstack.js/blob/master/demo/react.html
The Gridstack ( ) component is simply called in parent component, no customization is done.
Your environment
Steps to reproduce
Demo made with WP Studio, this is a temporary site which will destroy itself in 7 days (until May 6.th 2024):
https://intellectual-wildfowl.wp.build/wp-admin/post.php?post=245&action=edit
If anyone wants to give a look at this, I will provide login credentials
A video:
https://github.com/gridstack/gridstack.js/assets/25330880/fec38279-734f-4fe3-8be0-f1a6ae2f1ec3
Expected behavior
Obviously, there shouldn't be error when re-initializing Gridstack in iframe.
The text was updated successfully, but these errors were encountered: