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

Improve Block Toolbar Semantics/Accessibility #54513

Closed
wants to merge 60 commits into from

Commits on Oct 13, 2023

  1. Move Selected Block Tools into the header toolbar in the DOM but pres…

    …erve all visual interactions
    
    This is a big commit with a large potential for bugs. Think of this as a spike or POC for now. There'll be a lot to address. Some general TODOs:
    - [ ] Refactor shared code between empty-block-inserter and selected-block-tools
    - [ ] More explicitly pass the popover slot and content ref into the SelectedBlockTools
    - [ ] Shortcut/keystrokes for returning from the toolbar to where the cursor was before moving into the toolbar
    - [ ] Inline Tools either move to the top toolbar or get inserted into the main block toolbar (think image caption formatting tools)
    - [ ] Visual styles for the top toolbar
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    8e521f7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    deacf25 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4ede8a7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    45ebf2f View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fea3c9f View commit details
    Browse the repository at this point in the history
  6. Move lastFocus into redux store

    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    ed8541b View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    7728101 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    271b0eb View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    647ecf5 View commit details
    Browse the repository at this point in the history
  10. Add focusEditorOnEscape to NavigableToolbar to return focus to editor

    If we remove the bubblesVirtually from the block-controls slot, then the event will bubble in the DOM as normal (instead of the React Tree only since bubblesVirtually uses createPortal for the fills). This means we could handle the event without any forwardRefs as we don't need to block the escape shortcut keypress event from the React Tree.
    
    However, we assume bubblesVirtually was made for a reason. So, we're unsure if something would break.
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    0f34d47 View commit details
    Browse the repository at this point in the history
  11. Consolodate block tools into one fill component and conditionally ren…

    …der into slot or within block editor
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    55cbde4 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    6162985 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    b749291 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    1cdf89e View commit details
    Browse the repository at this point in the history
  15. Scroll toolbar

    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    c15c5b1 View commit details
    Browse the repository at this point in the history
  16. isBlockToolsCollapsed state and styles for edit site header

    Move isCollapsed state from the block-contextual-toolbar into the site editor header, as it is only needed and related to the site editor header. This is not a state the block toolbar needs to know about.
    
    Co-authored-by: Andrei Draganescu <me@andreidraganescu.info>
    jeryj and draganescu committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    1e54077 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    85ac216 View commit details
    Browse the repository at this point in the history
  18. Only allow block tool collapse to impact large viewports

    If the block toolbar was collapsed in the large viewport, then the viewport is resized to be small enough that the toolbar should move to underneath the header, the toolbar would be in the collapsed state so it would not show.
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    a6e542e View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    818bdf7 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    2364439 View commit details
    Browse the repository at this point in the history
  21. Fix select mode in top toolbar

    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    7551136 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    6c3dcdf View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    ab1c29e View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    accedb5 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    e24d203 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    da3a1ea View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    484f118 View commit details
    Browse the repository at this point in the history
  28. Pass keydown listener into navigable toolbar instead of removing bubb…

    …lesVirtually from the toolbar group slot
    
    Removing bubblesVirtually from the toolbar group slot prevents any dynamically added toolbar buttons from firing their click event. This can be seen when cropping an image, you press Crop, then the Apply and Cancel buttons get added to the toolbar. Those button events don’t fire properly and is mentioned as an issue in the bubblesVirtually slot fill PR: #19242
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    6addc4f View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    9cd01cf View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    6c80738 View commit details
    Browse the repository at this point in the history
  31. Resizeable box (for resizing cover block) should use after block popo…

    …ver slot
    
    The block-popover slot is reserved for block-toolbar like popovers, such as the captions popover, and will appear in the header dom. Popovers that don't need to be in the head should use the __unstable-block-tools-after slot
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    6bed696 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    5ddeb0b View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    6ebb4d9 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    cc0b4dd View commit details
    Browse the repository at this point in the history
  35. Clarify getLastFocus description

    Co-authored-by: Andrei Draganescu <me@andreidraganescu.info>
    jeryj and draganescu committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    bcfb65b View commit details
    Browse the repository at this point in the history
  36. Update docs

    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    e96401d View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    f1066c4 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    92f95f1 View commit details
    Browse the repository at this point in the history
  39. Refactoring continued

    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    e565a8a View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    b1da15c View commit details
    Browse the repository at this point in the history
  41. Refactor to remove data from useSelectedBlockToolProps that were not …

    …used by the empty block inserter
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    bf5e941 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    8072e7a View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    267863a View commit details
    Browse the repository at this point in the history
  44. Hide block tools popover behind post header

    This is a tricky one. To hide the popover behind the header when it's within the header DOM means we need to have something within the header with a higher z-index for the popover to hide behind. Everything else in the header needs a high z index to be be on top of the header.
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    ba354bd View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    d2167e7 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    d23a4cf View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    60a8d69 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    bc03bd1 View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    3788c00 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    07ac3b8 View commit details
    Browse the repository at this point in the history
  51. Fixing more positioning hacks with flexbox

    Adding position absolute to all instances of __background-style lets it be excluded from all flexbox calculations, which is what we want. If the div is empty, it still gets calculated and pushes elements around.
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    fa398e1 View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    c3b650c View commit details
    Browse the repository at this point in the history
  53. Remove unnecessary test

    This test was already covered well by 'ensures base block toolbars use roving tabindex'
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    8d57813 View commit details
    Browse the repository at this point in the history
  54. Handle escape on toolbar via toolbar event listener instead of children

    This method requires forwarding a ref from the editor level down to the navigable toolbar so that the escape unselect shortcut can be blocked and the navigable toolbar event listener will still fire.
    
    Blocking the global escape event shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:
    - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar
    - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.
    - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.
    
    Also, this is better than attaching it to all of the children in the block toolbar because when new items are attached to the toolbar (such as via the bubblesVirtually slots or the apply/cancel buttons when cropping an image) we can still catch the events. Otherwise, those buttons are added after the mount, and the children don't receive the listener.
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    4c662de View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    0c54480 View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    a291e1f View commit details
    Browse the repository at this point in the history
  57. Switch to object notation to avoid bugs like I introduced where the o…

    …rder of the params matters
    jeryj committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    c12381e View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    1449b4a View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    9cc91d9 View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    3a96e02 View commit details
    Browse the repository at this point in the history