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
The current version works fine, but has several issues:
addEventListener('hashchange') is added in every iframe on the page, whereas it could be set just once in the EmbeddedIFrameController.
A timeout had to be added because I cannot ensure, within the iframe, that all other iframes in its parent are fully loaded and that the parent’s height has been fully adjusted.
If multiple iframes contain the same anchor, the scroll might happen to an iframe that is not currently visible on the screen. Ideally, scrolling should happen to the first found anchor across all iframes at the EmbeddedIFrameController level.
I also realized that the addAnchorLinkHandlers method within the iframe won’t work correctly if the link points to a different iframe on the page.
Therefore, I suggest discussing a possible future refactor:
The root controller should provide a loading status — for example, right now we can get information about the loading status of all iframes here, but the result of Promise.all is not utilized anywhere: EmbeddedContentRootController.ts#L84
Ideally, we should also ensure that the parent container has finalized the height of all its iframes. (I’ve tried various approaches with ResizeObserver, but haven’t found a clean solution yet.)
I would prefer not to overload the EmbeddedContentRootController with link-handling logic. Instead, this should be configurable via an additional argument or method. There’s already a forEach method, so this could be something like executeOnRootController.
It will also be necessary to somehow dispatch clicks on # links from child iframes to handle them in the root controller (because the link may refer to the header in another iframe). I’m leaning towards something similar to this approach.
The handler for clicking on the link and the handler for the url must be the same – scroll to the first element with the specified id (we search in all iframes). Thus, there will be one handler, and three sources of its trigger: when the page loads, there is already a hash in the url, when the hash is changed, and when clicking on a link with a hash
Notes
execute scrollIntoView in the parent controller
set up the exchange of events between the root controller and the child
take into account the isolated mode
The text was updated successfully, but these errors were encountered:
The current version works fine, but has several issues:
addEventListener('hashchange')
is added in every iframe on the page, whereas it could be set just once in theEmbeddedIFrameController
.EmbeddedIFrameController
level.addAnchorLinkHandlers
method within the iframe won’t work correctly if the link points to a different iframe on the page.Therefore, I suggest discussing a possible future refactor:
EmbeddedContentRootController.ts#L84
EmbeddedContentRootController
with link-handling logic. Instead, this should be configurable via an additional argument or method. There’s already aforEach
method, so this could be something likeexecuteOnRootController
.Notes
The text was updated successfully, but these errors were encountered: