useDisabled
hook: Fix problem with not working in iframe
#47459
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #47293
More fundamental solution than #47331
What?
This PR solves the problem of the
useDisabled
hook not working on iframes and ensures that theinert
attribute is properly applied to the child element.As a result, the issue reported in #47293, where tools are duplicated, will be fixed.
Why?
The
useDisabled
hook grants the inert attribute if its child element is a instance ofHTMLElement
. However, as far as I know,instanceof HTMLElement
is implicitly treated as awindow.HTMLElement
, so it does not meet this condition in an iframe.As a result, within the iframe, this hook does not grant the
inert
attribute.As you can see in the video below, in the classic theme, the post editor is not an iframe, so the inert attribute is given and the issue reported in #47293 does not occur. However, in the case of the block theme, because it is an iframe, the inert attribute is not given and the problem occurs:
552200a7a9b86c2d5a5fac06b4653bfe.mp4
How?
Refer to
defaultView
to check instances relative to thedefaultView
.More fundamentally, as pointed out in this comment, the problem might be that the clientId is shared within the hoge block.
This issue may need to be investigated separately.
Testing Instructions