• Robert Knight's avatar
    Make sidebar app responsible for opening sidebar to edit draft · f6ac11fc
    Robert Knight authored
    Move the responsibility for opening the sidebar when there is a draft to
    edit from the guest into the sidebar's `FrameSyncService`.
    
    The initial motivation for this was to make the logic in the
    `beforeAnnotationCreated` event handler in the `Sidebar` class work if
    the annotation is created in a non-host guest frame. The plan was to
    make the sidebar send an `openSidebar` request with custom options that
    would trigger the logic that used to be in the `beforeAnnotationCreated`
    event handler.
    
    However it appears that focusing the sidebar frame is no longer necessary. In my
    testing the input field in the sidebar was successfully focused regardless
    of whether `iframe.contentWindow.focus()` was called or not. Therefore I
    have just removed the handler.
    
    Even though the original need no longer exists, moving the logic still
    seems sensible because logically it is the sidebar application that
    knows it is awaiting user input after a new draft is created. It also means that
    if we do find a need to re-introduce the frame-focusing logic that used
    to be in the `beforeAnnotationCreated` handler, we can do so in a way
    that works with annotations created in non-host frames.
    f6ac11fc
sidebar-test.js 26.8 KB