-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Add link modal does not focus ! #955
Comments
Without demo page or steps to reproduce, I can't help. |
Hello, I can give you access if required (on private) Regards |
Solved now. var $modal = $('<div/>', {class: prefix + 'modal ' + prefix + 'fixed-top'})
.css({
- top: t.$box.offset().top + t.$btnPane.height(),
- zIndex: 99999
})
- .appendTo($(t.doc.body));
+ .appendTo($(t.$btnPane)); In css .trumbowyg-modal {
position: absolute;
+ top: 100% !important;
+ z-index: +1; So the modal is always related to the toolbar in any dialog depth. Best regards |
Thanks so much @Yves-K! This is exactly the bug that we were running into and your fix works great! Kudos! The problem was the same. We have a trumbowyg editor initialized inside a bootstrap modal. We weren't able to interact with the add link or add image dialogs until trying this fix! |
On closer examination, this is not a bug with trumbowyg but rather an issue with the Bootstrap modal enforcing focus. This answer from stack overflow shows how to fix it: https://stackoverflow.com/a/43104663/4531155. For Bootstrap 3 modals: $.fn.modal.Constructor.prototype.enforceFocus = function() {
var $modalElement = this.$element;
$(document).on('focusin.modal',function(e) {
if ($modalElement[0] !== e.target
&& !$modalElement.has(e.target).length
&& $(e.target).parentsUntil('*[role="dialog"]').length === 0) {
$modalElement.focus();
}
});
}; |
I confirm that the solution provided by @Yves-K is working well. In my case, (same as @rsmithlal ) I was using the text editor inside a Bootstrap 4 Modal. With this tweak works fine. However I had to change the trumbowyg-modal-button css class because it was shown with opacity. |
I've found another way around this. I had this problem with the image plugin. Inside of the bootstrap 4 modal shown event. $("#messagemodal").on('shown.bs.modal', function () { worked like a charm! |
Just remove the tabindex attribute from the modal. It should solve the issue with less efforts. |
Solving the issues described above, I have proposed a pull request in which the modal is appended right after the Trumbowyg editor container, so that the modal can be focused on in Bootstrap modals without any additional side effects. Adding the modal into the button pane as proposed previously by @Yves-K would require unnecessary modifications in CSS. |
FYI Changing this: var $modal = $('<div/>', {
class: prefix + 'modal ' + prefix + 'fixed-top'
}).css({
top: t.$box.offset().top + t.$btnPane.height(),
zIndex: 99999
}).appendTo($(t.doc.body)); To this: var $modal = $('<div/>', {
class: prefix + 'modal ' + prefix + 'fixed-top'
})
.css({
zIndex: 99999
})
.appendTo($(t.$box)); Did the trick for me on Bootstrap 5. |
I had the same issue on Bootstrap v5 and found this solution : Add this data-bs-focus="false" :
Worked for me. |
Hello,
Deep testing Trumbowyg i'm impressed...
Version 2.15.2 with custom css
Test on Chrome, Opera, FireFox
Clicking on the "add link" (not minimal) button, modal opens and displays fields but cannot focus on URL text field.
So it's impossible to add a link.
Works on your demo with the same version...
Any idea ? How can i help ?
Best regards
The text was updated successfully, but these errors were encountered: