-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[RFC] Native dialogs replacing the Bootstrap ones #39344
Conversation
(I had an issue with dvw not being supported but it was my browser not being on the version released on tuesday) |
@@ -62,8 +62,8 @@ public function onDisplay($name) | |||
return; | |||
} | |||
|
|||
$link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' | |||
. Session::getFormToken() . '=1&editor=' . $name; | |||
$link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice if all of these links were constructed in the same way. eg
&editor=' . $name . '&' . Session::getFormToken() . '=1';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These plugins have huge issues as the editors plugins. Neither can use com_ajax, neither could support the newer Namespaced version, etc. So I guess someone should check the whole stack concerning the editor and their buttons.
Fwiw it should be nice to have a helper fn to build the urls, so I support the idea but there are more fundamental problems that need some proper solution instead of keep doing monkey patches...
I will need some time to check it |
Might be easier to check the code here: https://github.com/dgrammatiko/joomla-modal/tree/main/src |
For begining we should draw some concept, how it should work. I imagine it like that (if we choose the custom element path): // Iframe
const popup = document.createElement('joomla-modal');
popup.type = 'iframe';
popup.url = 'blabla/url/';
popup.show();
// inline
const popup = document.createElement('joomla-modal');
popup.type = 'inline';
popup.popupContent = '<strong>blabla very strong text</strong>';
popup.show();
// image
const popup = document.createElement('joomla-modal');
popup.type = 'image'; // or 'video'
popup.url = 'blabla/url-to-image.jpg'; // or video.webm
popup.show();
// prompt, can be added later
const popup = document.createElement('joomla-modal');
popup.type = 'prompt';
popup.popupContent = '<strong>Are you sure?</strong>';
popup.buttons = [{label: 'Yes', onClick: blablaClaaback}, {label: 'Not', onClick: blablaClaaback2}] // click on any of this also destroys the popup.
popup.show();
// In theory we can detect 'type' based on url or popupContent property Showing popup: // show() method automaticaly append itself to the document.body, when popup.parent === null;
popup.show();
// user append popup where he want then show
blablaElement.addChildren(popup);
popup.show(); Closing and destroing popup: popup.close(); // Just hides the popup, allow to show it again later
popup.destroy(); // Close (when open) and remove from DOM , kind of optional, or we use popup.parent.removeChild() Events: const popup = document.createElement('joomla-modal');
// After popup opened
popup.addEventListener('joomla-modal:shown', (event) => {});
// After popup closed
popup.addEventListener('joomla-modal:closed', (event) => {});
popup.show(); The popup should give access to its content, so User can interact with it, kind of: console.log(popup.popupBody); Other things:
All namings is subjective, can be changed, it just for ilustration. One note I seen in code: do not use popup.setAttribute('url', button.href); // This is potato
popup.url = button.href; // This is good |
I also agree with all with only couple of remarks:
Everything should be properties but also attributes should be allowed for strings, bool, num if we want a declarative solution also (we can sync them), maybe the modal wrapper doesn't need any attributes and those should only be on the
True, also option for closing it when clicking on the backdrop (dialog element doesn't support that ootb)
Lets use classes for the styling/sizing, I think I left a dummy |
About setAttribute, I just looking how native elements works, example when we do img: // we do
const img = new Image() // or document.createElement('img');
img.src = 'path/to/image'
// but not
img.setAttribute('src', 'path/to/image'); Of course both is valid, but that more clear I think. |
I think you misunderstood me, what I meant was:
They both could exist in total harmony, it's just an added bonus if the property is named as the attribute and someone could use them interchangeably (eg |
@Fedik so I'm gonna prototype a class (and not a custom element wrapper) for the modal factory and tackle the declarative cases later. I will ping you when something is reviewable (will move the code to Joomla-projects/custom-elements to have some tests) |
Pull Request for Issue #32473 .
Summary of Changes
This is just a rough implementation nowhere near production!!!
The styling is extremely basic!!!
FWIW editing an article in com_content is the way to test this. That view went from 11 modals depending on Bootstrap to vanilla
dialog
with a little wrapper.Also the DOM nodes went from
to
Testing Instructions
Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
Publishing tab, Select user
Images & links, media select
Content tab, tinyMCE buttons:
Content tab, CodeMirror buttons:
Toolbar buttons versions:
Toolbar buttons preview:
Toolbar buttons a11y check:
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
@Fedik @brianteeman any comments here would be nice