You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Components: Clicking on iframe in the content close the modal #40912
Thank you for reporting this @Tropicalista. Do you have any suggestions on how this could be fixed so we can discuss them and move the issue forward? Thank you!
If this is still reproducible, we should consider submitting a PR rather than closing the issue, so that this is fixed for everyone. I would love to do this myself but the issue is beyond my technical expertise.
Hi,
This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
Thanks for helping out.
changed the title [-]It's impossible to type in TinyMce in modal [/-][+]Components: Clicking on iframe in the content close the modal[/+]on Oct 23, 2022
I've thought about it again, and it may be strange to set shouldCloseOnClickOutside to false to prevent the iframe in the modal content from being closed when clicked, because the iframe is inside the content, not outside it.
Ideally, I would like to not call onRequestClose when an iframe element in the content is clicked, but I am wondering what implementation would be smart.
Hey @ivdimova , the problem was not fixed. I had tried an approach with #45349 but (as you can read in the PR description) I didn't make much progress.
Feel free to work on a solution for this issue and I'll be happy to help with review & advice as necessary
Yes, I did work on it. Now, the best I can remember is the approach I was trying (fixing it inside useFocusOutside) had some little edge case that kept me from being satisfied with it.
If @ivdimova is also using the Modal component like in the OP by @Tropicalista, and we want to fix this in the library, it could be worth trying the alternative I'd mentioned above #40912 (comment). To restate it, remove useFocusOutside from Modal and instead utilize its overlay element to catch any outside pointer interaction to trigger the close.
If Ivelina is making a custom dialog/modal (or wants to try it to avoid waiting on a fix) the same approach should work. I.e. use an overlay element to trigger closing and don't rely on useDialog or useFocusOutside. useConstrainedTabbing must be employed so focus can't otherwise escape.
It could be worth trying the alternative I'd mentioned above #40912 (comment). To restate it, remove useFocusOutside from Modal and instead utilize its overlay element to catch any outside pointer interaction to trigger the close.
I don't currently have the capacity to work on this firsthand, but I'd happy to collaborate and help folks with advice and PR reviews.
If Ivelina is making a custom dialog/modal (or wants to try it to avoid waiting on a fix) the same approach should work. I.e. use an overlay element to trigger closing and don't rely on useDialog or useFocusOutside. useConstrainedTabbing must be employed so focus can't otherwise escape.
Would it be worth, at this point, revisiting useDialog and embed potentially revised functionality directly in it?
I was not aware of this issue and created a similar one at #50436
Worth mentioning this problem is now even more important because the Classic block now opens in a modal dialog. The TinyMCE editable area within the modal dialog is in an iframe. The specific problem for this block was worked around by not passing the onRequestClose prop (which expects a callback to handle the close behavior). That disables the 'close on click outside' behavior but unfortunately disables also the 'close on press the Escape key` behavior. As such, it's not a real solution to the problem and alters the expected behavior of the modal dialog.
As you can read above, we've been discussing possible solutions, but we haven't landed on one (or haven't found the time to work on it) just yet — feel free to open a PR in case you have an approach in mind, I'll be more than happy to collaborate on it!
This library has onRequestClose prop, similar to Gutenberg's Modal component. However, clicking on an iframe in a modal does not close the modal. I have not investigated this in detail yet, but this implementation might be a solution.
@t-hamano From a brief look at that library and your sample, the reason it works is because it utilizes a click handler on the overlay element. Gutenberg’s Modal also has any overlay element and so the same could be done with it (as I've mentioned previously).
I've made a PR with that approach and linked this issue to it.
@stokesman opened Modal: fix closing when contained iframe is focused #51602 as a potential fix to the issue, where he removed useFocusOutside from the Modal component and added an event handler instead (although it's currently stuck because of a conflict with command center)
@ciampo opened Try/use focus outside iframe #52040 as another potential fix, amending the useFocusOutside to support the iframe use case (although the solution is a bit hacky and requires thorough testing, in case there are more edge cases)
Activity
Tropicalista commentedon May 9, 2022
The problem is partially solved by adding
shouldCloseOnClickOutside={ false }However some glitch still remaining because cotextual menu need some css because the element are positioned on a lower z-index.
t-hamano commentedon May 15, 2022
Hi @Tropicalista,
I've written test code and was able to reproduce this problem.
I think the cause may be that
onRequestCloseis called when the iframe in the modal gets focus.Here is the test code.
I used
@tinymce/tinymce-reactand dummy iframe content.See sample code
b4940356ef8e64c108a199fcc0590c93.mp4
This might be a problem that should be corrected on the
Modalcomponent oruseFocusOutsidehook.Does anyone have a good idea?
mrfoxtalbot commentedon Sep 19, 2022
Thank you for reporting this @Tropicalista. Do you have any suggestions on how this could be fixed so we can discuss them and move the issue forward? Thank you!
Tropicalista commentedon Sep 19, 2022
At the moment I use
shouldCloseOnClickOutside={ false }and it's working. You can see it in my Formello plugin.t-hamano commentedon Sep 20, 2022
Thank you for the reply, @Tropicalista.
If so, is it ok to close this issue?
mrfoxtalbot commentedon Sep 20, 2022
If this is still reproducible, we should consider submitting a PR rather than closing the issue, so that this is fixed for everyone. I would love to do this myself but the issue is beyond my technical expertise.
@Tropicalista, @t-hamano, would you consider submitting a PR to fix this? Thank you!
github-actions commentedon Oct 21, 2022
Hi,
This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
Thanks for helping out.
[-]It's impossible to type in TinyMce in modal [/-][+]Components: Clicking on iframe in the content close the modal[/+]t-hamano commentedon Oct 23, 2022
I've thought about it again, and it may be strange to set
shouldCloseOnClickOutsideto false to prevent the iframe in the modal content from being closed when clicked, because the iframe is inside the content, not outside it.Ideally, I would like to not call
onRequestClosewhen an iframe element in the content is clicked, but I am wondering what implementation would be smart.cc @ciampo @mirka
17 remaining items
ciampo commentedon Apr 11, 2023
Hey @ivdimova , the problem was not fixed. I had tried an approach with #45349 but (as you can read in the PR description) I didn't make much progress.
Feel free to work on a solution for this issue and I'll be happy to help with review & advice as necessary
ciampo commentedon Apr 11, 2023
@stokesman , out of curiosity did you even get to work on this ?
stokesman commentedon Apr 12, 2023
Yes, I did work on it. Now, the best I can remember is the approach I was trying (fixing it inside
useFocusOutside) had some little edge case that kept me from being satisfied with it.If @ivdimova is also using the
Modalcomponent like in the OP by @Tropicalista, and we want to fix this in the library, it could be worth trying the alternative I'd mentioned above #40912 (comment). To restate it, removeuseFocusOutsidefromModaland instead utilize its overlay element to catch any outside pointer interaction to trigger the close.If Ivelina is making a custom dialog/modal (or wants to try it to avoid waiting on a fix) the same approach should work. I.e. use an overlay element to trigger closing and don't rely on
useDialogoruseFocusOutside.useConstrainedTabbingmust be employed so focus can't otherwise escape.ciampo commentedon Apr 27, 2023
I don't currently have the capacity to work on this firsthand, but I'd happy to collaborate and help folks with advice and PR reviews.
Would it be worth, at this point, revisiting
useDialogand embed potentially revised functionality directly in it?afercia commentedon May 22, 2023
I was not aware of this issue and created a similar one at #50436
Worth mentioning this problem is now even more important because the Classic block now opens in a modal dialog. The TinyMCE editable area within the modal dialog is in an iframe. The specific problem for this block was worked around by not passing the
onRequestCloseprop (which expects a callback to handle the close behavior). That disables the 'close on click outside' behavior but unfortunately disables also the 'close on press the Escape key` behavior. As such, it's not a real solution to the problem and alters the expected behavior of the modal dialog.ciampo commentedon May 23, 2023
Thank you for the comment, @afercia !
As you can read above, we've been discussing possible solutions, but we haven't landed on one (or haven't found the time to work on it) just yet — feel free to open a PR in case you have an approach in mind, I'll be more than happy to collaborate on it!
t-hamano commentedon Jun 16, 2023
I have created a sample using react-modal to explore the ideal solution to this problem.
Code Sandbox: https://codesandbox.io/s/vigorous-carson-6grq7f?file=/src/index.js
This library has
onRequestCloseprop, similar to Gutenberg'sModalcomponent. However, clicking on an iframe in a modal does not close the modal. I have not investigated this in detail yet, but this implementation might be a solution.03d60681174928d73ebeebe26b54148b.mp4
stokesman commentedon Jun 16, 2023
@t-hamano From a brief look at that library and your sample, the reason it works is because it utilizes a click handler on the overlay element. Gutenberg’s
Modalalso has any overlay element and so the same could be done with it (as I've mentioned previously).I've made a PR with that approach and linked this issue to it.
ciampo commentedon Sep 1, 2023
Hey all, back from some extended AFK.
I'd like to assess the status of the issue. From what I can see:
Modal: Fix loss of focus when clicking outside #52653 andModal: Nuance outside interactions #52994 got merged, although I'm not sure if it affects this issue at allModal: fix closing when contained iframe is focused #51602 as a potential fix to the issue, where he removeduseFocusOutsidefrom theModalcomponent and added an event handler instead (although it's currently stuck because of a conflict with command center)useFocusOutsideto support theiframeuse case (although the solution is a bit hacky and requires thorough testing, in case there are more edge cases)What are your thoughts? (cc @t-hamano @afercia )
stokesman commentedon Sep 1, 2023
I'm pretty sure this is still present. Neither of the Modal PRs I merged were meant to affect it. Hope you had a great time AFK Marco!
afercia commentedon Sep 8, 2023
@ciampo thanks for the ping. I commented on #51602 (comment)