ckeditor's popup input fields dont work when used with bootstrap 5 modal (ckeditor 4)
Asked Answered
U

4

8

I have come across an error while using ckeditor in bootstrap 5 modal and it looks like it's a very known error and many have given solution for it for different bootstrap versions but i am not able to figure out one for bootstrap 5, please have a look.

Here is the problem with solution:- https://stackoverflow.com/a/31679096

Other similar problems:-

CKEditor Plugin: text fields not editable

Bootstrap with CKEditor equals problems

Mainly what would be the alternative of below line for bootstrap 5. $.fn.modal.Constructor.prototype.enforceFocus

If I search for it in bootstrap 4 js file I'm able to find fn.modal.Constructor in there but not in bootstrap 5. Please if someone can recreate the verified solution in the above link according to bootstrap 5 it would be very appreciated. Thank you for your time.

image describing problem

Also few notes:-

  1. All the other input types like checkboxes and dropdown works but not just text field.

  2. I have also tried removing tabindex="-1" from bootstrap modal code but the problem remains.

Undoubted answered 21/9, 2021 at 13:7 Comment(1)
Please take the tour. Solutions don't go in your question.Euripides
N
6

Thanks for this. Saved me a lot of head scratching. As of Bootstrap 5.3, this requires a small tweak:

bootstrap.Modal.prototype._initializeFocusTrap = function () { return { activate: function () { }, deactivate: function () { } } };
Narcis answered 12/1, 2023 at 3:3 Comment(2)
This answer is very useful. it saved my time. Thanks a lot dearAtropine
Nice! I was also able to apply this to bootstrap.Offcanvas component similar to Modal, as the FocusTrap was also applied there.Carolecarolee
W
2

Not sure if you figured out the answer to this yet, but I've had this same issue with a sweetalert2 modal. I scoured bootstrap's source code and found that you can remove the focus with this:

$.fn.modal.Constructor.prototype._initializeFocusTrap = function () { return { activate: function () { }, deactivate: function () { } } };

Works as of Bootstrap 5.1.3

Weak answered 4/4, 2022 at 14:10 Comment(0)
M
0

Bootstrap does not support nesting modals disabling enforce focus will allow other modals to get focused: <Modal enforceFocus={false}>

Mutazilite answered 16/10, 2022 at 14:13 Comment(1)
Your answer could be improved by providing an example of the solution and how it helps the OP.Capping
R
0

Surely you've already solved it, but so others who encounter the error have it, the solution for me, with Bootstrap 5.3 and CKEditor 4, was to add data-bs-focus="false" to the modal's HTML.

By deactivating the modal's automatic focus, it ensures that the elements within the modal are ready to be initialized correctly when the shown.bs.modal event is triggered

Reube answered 5/2 at 18:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.