Skip to content
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

TinyMCE dialogs input fields not working with Materialize #5972

Open
Hydr555 opened this issue Jun 8, 2018 · 9 comments
Open

TinyMCE dialogs input fields not working with Materialize #5972

Hydr555 opened this issue Jun 8, 2018 · 9 comments

Comments

@Hydr555
Copy link

Hydr555 commented Jun 8, 2018

Hey!

I've an issue using Materialize and TinyMCE within a modal.
TinyMCE dialog input fields are not accessible.
I tried to stop events propagation but it doesn't work.

$(document).on('focusin', function(e) {
  if ($(e.target).closest(".mce-window, .moxman-window").length) {
    e.stopImmediatePropagation();
  }
});

This code works with jQueryUI dialog but not with Materialize.
I think the dropdown component had a similar issue: #1683

Please take a look at this CodePen: https://codepen.io/anon/pen/rKWxwK

Thanks for assistance.

@AdmiralLordM
Copy link

I can confirm the issue exists. It was working with the previous versions but updating to 1.0 breaks TinyMCE input fields on their popups.
a temporary fix would be lovely until this is sorted on master

@cakesforfree
Copy link

This sucks. i had to re create my views in order to work around this. Please fix it

@Blazzike
Copy link

Blazzike commented Feb 7, 2019

Possible solution would be to check the focused event's element's z-index, if it's lower than that of a modal element, cancel.

_handleFocus(e) {
  if (!this.el.contains(e.target)
     && this._nthModalOpened === Modal._modalsOpen
     && document.defaultView.getComputedStyle(e.target, null).zIndex < 1002) {
    this.el.focus();
}

@sigma-technology
Copy link

sigma-technology commented Feb 22, 2019

I'm also experiencing this issue. Here's a codepen for the v1 release.

@Blazzike where would that code go?

@Blazzike
Copy link

I'm also experiencing this issue. Here's a codepen.

@Blazzike where would that code go?

This is a change to Materialize's source code. Specifically the modal.js file. You can make the change by replacing the current _handleFocus function and recompiling Materialize.

@sigma-technology
Copy link

sigma-technology commented Feb 22, 2019

Thank you for the quick response. Recompiling the JS isn't really an option for us unfortunately as we're using NPM.

However, your code does work perfectly - I've managed to override that function using $.extend, so anyone using jQuery should be able to do the same:

$.extend(M.Modal.prototype, {
  _handleFocus(e) {
    if (!this.el.contains(e.target)
       && this._nthModalOpened === M.Modal._modalsOpen
       && document.defaultView.getComputedStyle(e.target, null).zIndex < 1002) {
      this.el.focus();
    }
  }
});

I've updated the codepen.

@Dogfalo I realise this isn't technically a Materialize issue, but would it be possible to include some sort of generic solution such as the one above into the next release?

@calvaradocl
Copy link

I confirm that the fix by @sigma-technology works great with Materialize and TinyMCE. I've been trying to use the method that was posted for JQuery-UI and bootstrap without luck. Thanks!

@dwiky
Copy link

dwiky commented Jan 7, 2020

@sigma-technology thankyou dude, you're a live saver..
that code is working like a charm.. I've been strugling with this issue for hours...

@nikolaysm
Copy link

It can also be resolved to setting dismissible: false

$(document).ready(function() {
    $('.modal-tinymce').modal({dismissible:false,});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants