Review main Merged

93083[TASK] Replace ContextPanel with Modal

Benjamin Kott CR +2 V +2 Expert +117 −922 updated 03/20/26, 12:00

Commit message

Remove the custom typo3-backend-context-panel web component
and replace it with the existing Modal API. The Modal already
supports edge-docked positions, making a separate offcanvas
component unnecessary.

Introduce two new Modal options:

- Position "sheet": docks the modal to the end edge on
  wide viewports and switches to a bottom sheet on narrow
  screens (<=768px). This replaces the context panel's
  placement and responsive behavior.

- Size "expand": sets the modal height to 100%, allowing
  it to span the full extent of the docking edge. Unlike
  "full", it does not override the width.

Make the `typo3-modal-hide` event cancelable so that listeners
can call `preventDefault()` to defer closing. The contextual
record edit trigger uses this to ask the iframe form whether
it has unsaved changes before allowing the modal to close.

The contextual record edit trigger now opens an iframe modal
with position: sheet and size: expand instead of creating a
context panel element. The styleguide ContextPanel component
page is removed; the new position and size are available in
the existing Modal playground.

Review

  • Code review CR +2 Done
    • Benjamin Kott +2
    • Benjamin Franzke +1
    • Josua Vogel +1
  • Verified V +2 Done
    • Benjamin Kott +2
    • Benjamin Franzke +1
    • Josua Vogel +1
    • core-ci +1 CI

Issues 2

Files 19

Review log 2425

  1. Benjamin Kott uploaded patch set 1 03/05/26, 14:16

  2. core-ci voted on patch set 1 V +1 03/05/26, 14:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97410

  3. Oli Bartsch commented on patch set 1 03/05/26, 17:09

    No it does not. The context panel is always 100% height on wide screens and the size option defines the width, the panel expands into the frame. Additionally via placement, the panel can be attached to any side of the window, which is needed for further components. The modal does not provide these options. As already mentioned in the other patch, I don't think it is a good idea to make modal a god component. There at way to much options already. That said, can we please agree on talking to each other before pushing patches like this?
  4. Benjamin Franzke commented on patch set 1 03/05/26, 18:46

    Reply

    > There at way to much options already. Hey Oli, friendly reminder that you actually reviewed and acknowledged this functionality a few weeks ago: 92140: [TASK] Add modal positions, header visibility and static options | https://review.typo3.org/c/Packages/TYPO3.CMS/+/92140 > Reviewed-by: Oli Bartsch <bo@cedev.de> > Tested-by: Oli Bartsch <bo@cedev.de> Repeating the same pattern multiple times results in a state where we have a hard time maintaining our codebase and keeping UX and functionality aligned. Yes, sometimes overly abstracted code complicates things… …But this is different. Your context-panel introduced legacy technology (fixed positioning with unneeded backdrops), broken accessibility, broken classic (non-overlay) scrollbars [1] and zero value over the Modal API. Our Modal API is really just a unifying wrapper around `<dialog>` these days, that contains our UX patterns that we apply to the browser dialog API. You may even look at examples like `inline-control-container` vs `files-control-container` where it seemed like a good idea to duplicate a lot of logic, but now we have multiple broken components – see issues like https://forge.typo3.org/issues/96135 – and a hard time to get this stuff cleaned up. [1] https://developer.chrome.com/docs/css-ui/scrollbar-styling#classic_and_overlay_scrollbars
  5. Benjamin Franzke voted on patch set 1 CR +1 V +1 03/09/26, 15:06

  6. Oli Bartsch commented on patch set 1 03/09/26, 17:27

    Reply

    Thanks for the reminder. As mentioned several times already, I used the Modal API in the first iterations, but the enhancements provided in said patch were not sufficient for the new component. I also did not want to introduce even more options to the Modal API, which I have already pointed out. For that reason, I decided to implement a dedicated component that only provides the required functionality. While this patch extends the Modal API, it still does not cover the necessary requirements I mentioned in my first comment: a component with always 100% height, variable width, and the ability to attach to any side.
  7. Oli Bartsch commented on patch set 1 03/09/26, 17:40

    Reply

    I may not have made this clear. If the common consensus is to use a single component (the Modal API) for all kinds of dialogs, even if that results in a rather complex class with many options that may depend on each other, that is fine with me. However, the requirements I outlined here still need to be met.
  8. Benjamin Kott commented on patch set 1 03/09/26, 21:18

    Reply

    A variable width is NOT desired, so it was fixed here (not usable on large screen otherwise) it has set the new height and also the positions and behaves exactly like the previous implementation without the limitation on variable width on desktop. these 2 options are now added for size and also position to the modal api. so, i do not understand the comment. because what you are asking for is here. - see size expand - see position sheet the only other thing that was needed was that the event for hide can now be canceled
  9. Benjamin Kott commented on patch set 1 03/09/26, 21:22

    and yes, it´s desired to have less components that can be configured properly. otherwise, we have the same problem again we have with the inline control containers that do the same, slightly different, diverge and everything is hacked around it. and a quick "styling" fix becomes weeks of work.
  10. Oli Bartsch commented on patch set 1 03/10/26, 09:08

    Reply

    Current patch does not allow to attach the panel to any side of the screen. This is possible with the context panel and required. Why is adjustable width not desired and who decides this? There are use cases which require it. Maybe not on start / end positioning but when attaching to top or bottom (where width would be the height, therefore I named it "size"). Using different size options is needed. For example: Since v11 we want to place the clipboard in such component, sliding in from the bottom. This component does in no way need the same space (height) a FormEngine would need.
  11. Benjamin Kott commented on patch set 1 03/10/26, 18:41

    Reply

    this is why we can freely add new positions and sizes to accommodate for that need. this does not affect the complexity, nor does require anything else than to define the bot/right position and pick a size you like.
  12. Benjamin Franzke commented on patch set 1 03/10/26, 19:30

    Reply

    > If the common consensus is to use a single component (the Modal API) for all kinds of dialogs, even if that results in a rather complex class with many options that may depend on each other, that is fine with me. We don't have consensus that one new sizing option makes the modal "complex". I actually fully disagree. That is where abstraction shines. Please be aware that your single/restricted purpose context-panel failed to provide proper accessibility, rendered itself twice and your fix to migrate to `<dialog>` started to copy dozen of lines from modal.ts. This is exactly the point where you need to realize, that the context panel approach is wrong because you did not manage the complexity and failed. That's where we need abstraction, when individual complexity starts to be unmanageable and therefore unmaintainable. That is exactly the reason why we provide shared components, that *you* can use them, without introducing breaking behavior like you did. The only thing you need to do is to adhere to these rules and use what we already built for you.
  13. Oli Bartsch commented on patch set 1 03/10/26, 21:25

    Reply

    Either you are not reading my comments, or you chose to actively ignore them. I have now explained the requirements multiple times, and I will not repeat myself a fourth time. Pointing to fixable bugs to discredit the entire component is not a valid technical argument. By that logic, we could discard half the codebase. I won't engage with that line of reasoning. You know, you have your own contributions that shipped incomplete and unpolished, but that's not the point of this thread. Which brings me to the actual issue: the Modal API is not yours. It is a community component that many people contributed to, including myself. Treating it as your personal territory while telling me to simply fall in line is contemptuous of everyone who worked on it.
  14. Benjamin Kott commented on patch set 1 03/17/26, 07:22

    Reply

    i am also now resolving this conversation. as said, there is no need to duplicate code here, if we need additional placements, we can add them with little css and new positions here. i am not discussing personal feelings here. if we want to argue technical again, we can continue.
  15. Oli Bartsch commented on patch set 1 03/17/26, 10:44

    Context Panel requirements: The context panel behaves as slide-in offcanvas panel overlaying the viewport, used for contextual content (record editing, clipboard, etc.) without navigation. Content modes: iframe (default, deferred load), ajax (deferred), content (immediate). Placements: end (right, default), start (left), top, bottom. At ≤768px all placements collapse to a bottom sheet (80dvh, full width). Sizes: horizontal: small (30%, 400–600px), medium (40%, 600px–40vw), large (60%, 50–60vw). Vertical placements use height equivalents. Side placements are always full viewport height. Backdrop: Semi-transparent overlay. staticBackdrop (default=`false`) closes it, `true` shakes the panel on click. Both dispatch a cancelable event first. Escape: Closes the panel through the same close request flow. Ignored when a modal is open on top. Events: after open, after close, close request (cancelable, before close to prevent to block). Animation: Slide in/out, backdrop fade, shake on blocked close. All disabled under prefers-reduced-motion. Change of underlying API is fine as long as above requirements are met. Horizontal size is discussible. Current patchset lacks at least the following (did not yet fully analyse whether all necessary events are dispatched): * No start, top or bottom placement * Slide-In and Slide-Out animation is not given. Modal fades in and out instead. Furhermore: * Unsaved changes => Click outside of panel opens dialog => Click "Save and Close" => iframe is reloaded and "record saved" is displayed right before panel gets closed. This has been omitted intentionally in the context panel component implementation.
  16. Benjamin Kott commented on patch set 1 03/17/26, 11:46

    Reply

    General: The modal API already covers all mentioned content modes, backdrop handling, and escape key behavior out of the box. The cancelable close request, which was previously missing, has been added as part of this patch. Placements (start, top, bottom): These are fully supported by the modal API. The "sheet" option is not a separate placement but defaults to end (right) and falls back to a bottom sheet on viewports ≤768px. It can be combined with any available size, and additional placements can be introduced incrementally as use cases emerge. Slide-in / slide-out animation: The modal API has always combined a fade with a transition from the opening side, so this is not a change in behavior. A pure slide effect was intentionally avoided, as sliding an element across the full viewport width feels visually unjustified for a panel of this size. This can of course be revisited if a specific use case requires it. Unsaved changes / close flow: This is already covered. The hide event is cancelable precisely to handle this case, which is the same mechanism as before. The "Save and Close" → iframe reload → record saved → panel close sequence is fully supported through that event hook. Sizes: The horizontal size for side placements was deliberately set as a static value rather than following the medium preset. On wide screens, percentage-based widths stretch form content to the point of being unusable, which is something we already observe in other modules. The new expanded size covers vertical height requirements, and new sizes can be introduced at any point as concrete usage patterns emerge. Reduced motion: It is worth noting that prefers-reduced-motion was not handled correctly in the previous implementation either. This is something we should look into together as a follow-up, regardless of the current discussion. Looking forward to the full analysis of the remaining requirements and happy to go through any open points together.
  17. Benjamin Kott commented on patch set 1 03/17/26, 12:04

    Reply

    One correction to my previous note on reduced motion: the modal API does in fact handle prefers-reduced-motion correctly. It is the context editing panel being replaced that did not respect it properly, so this is actually an improvement with the current approach rather than an open issue.
  18. Oli Bartsch commented on patch set 1 03/17/26, 15:23

    Reply

    Thanks! Slide-in/out: You confirmed the modal API uses a fade and that's why it wasn't chosen as the underlying implementation. An offcanvas panel slides. That's not a preference, it's the defining behavior of the component. "Visually unjustified" is a design opinion, not a requirement conflict. If the modal API had been the right fit, we wouldn't be here. I don't want to open this discussion again. I'm fine with using Modal API. It clearly has advantages but we need a slide behaviour for this usage. It's a requirement of the context panel and not a "nice-to-have" UI feature. Random quote[1] form the internet (first google result): >The Modal component is a popup dialog box or overlay window that appears on top of the main content to display important information, forms, confirmations, or any interactive content. The Offcanvas component is a sidebar-like panel that slides into view from the left, right, top, or bottom of the screen. Placement: The "sheet" option is fixed to end. It cannot be combined with start, top, or bottom as independent placements. Since v11 Benni and I have a concrete use case: the clipboard in the Records module should slide in (from the bottom). A local patch already exists (based on current context panel component). This isn't something we can defer. I don't see a clean path to adding it later with the current approach. Unsaved changes: I think we're talking past each other. My implementation intentionally omitted the "Record saved" flash before panel close. It seems the timing issue between iframe reload and panel close is not properly handled right now. [1] https://www.jitblox.com/blog/bootstrap-offcanvas-and-modal
  19. Oli Bartsch commented on patch set 1 03/17/26, 16:03

    Reply

    Even this new video [https://www.youtube.com/watch?v=Y44_ytnmCIs&t=129s] calls the component "slide in editor feature".
  20. Benjamin Kott commented on patch set 1 03/17/26, 16:48

    Reply

    Slide-in / slide-out animation: The modal API has always combined a fade with a slide transition from the opening side, which is consistent with how Fluent UI implements its overlay drawer component [1]. It is worth acknowledging that Fluent UI fades in over the full width of the panel, though its default sizes cover considerably less area than what we are dealing with here, which further justifies avoiding a pure slide across the full viewport width. Interestingly, the reference provided in this thread describes offcanvas as something that "slides into view from the side", which is exactly what our implementation does. The element enters from the side regardless of whether opacity is also animated, so the combined transition does not contradict that definition. What we are implementing here is a modal side sheet in the truest sense of the term, an overlay panel that appears on top of content rather than pushing it aside, which is exactly what Material Design 3 defines as a modal side sheet [2]. A pure slide is a significant visual load for a panel that is not a persistent sidebar but a contextually generated overlay tied directly to user interaction. For users with prefers-reduced-motion enabled the distinction becomes entirely irrelevant as no transition is visible regardless of the chosen approach. [1] https://fluent2.microsoft.design/components/web/react/core/drawer/usage [2] https://m3.material.io/components/side-sheets/overview Placements (start, top, bottom, end): All side placements are fully supported by the modal API, including start, end, top, and bottom. The "sheet" option in the current implementation is not a placement at all but a behavioral descriptor that defines the responsive fallback to a bottom position on viewports ≤768px. The visual characteristics of a sheet, such as full viewport height, are handled through the size system, which can be adjusted to cover 100% height for start and end placements as needed. It is also worth noting that drawers and side sheets by definition enter from the side. Top and bottom entry points are fundamentally different interaction patterns and treating them as simple placement variants of the same component conflates two distinct UI concepts. Unsaved changes / close flow: The "Record saved" flash before panel close is a detail that was not explicitly included in the current implementation. It is worth noting that this omission was not even noticed during the migration, which suggests its impact on the user experience is minimal. If it is still considered important it can absolutely be added without any architectural concern. Clipboard in the Records module: This is a fundamentally different feature set involving always-present overlays with contained, persistent content. It is neither covered by the modal API, nor by side sheets or drawers, nor by the current context editing panel implementation. None of the solutions being discussed here are suitable for that use case and it should be treated as a separate discussion rather than a requirement that influences the current patch. Looking forward to continuing the discussion and happy to go through any remaining points together.
  21. Josua Vogel commented on patch set 1 CR +1 V +1 03/18/26, 10:25

    Regardless of the ongoing discussion, the change looks good to me and is working.
  22. Oli Bartsch commented on patch set 1 03/19/26, 09:14

    Reply

    I understand that my opinion is neither respected nor taken into account here. I will refrain from discussing this further, allowing you to be right, as we apparently will not make progress otherwise.
  23. Benjamin Kott commented on patch set 1 03/19/26, 11:42

    Reply

    That is not the intention at all, and I am sorry it feels that way. The goal was always to have a technical discussion on equal footing and your input has been taken seriously throughout. The patch was intentionally left open to allow this discussion to conclude properly. All raised points have been addressed and the decisions made have been documented in good faith. The remaining discussion around animation style is noted and can absolutely be revisited as a follow-up if needed. I fully respect your decision to step back from the discussion and will resolve the comments for now, leaving the patch open until tomorrow to allow any final input before moving forward based on the existing sign-offs.
  24. Benjamin Kott commented on patch set 1 CR +2 V +2 03/20/26, 12:00

    Reply

    Done
  25. Benjamin Kott merged patch set 2 03/20/26, 12:00