dingClientRect();
    const SCREEN_WIDTH = Math.min(window.innerWidth, window.screen.width);
    if (panelRect.right > SCREEN_WIDTH) {
      const newLeft = Math.max(MARGIN, x + MARGIN - panelRect.width);
      const newCaretOffset = left - newLeft;
      panel.style.left = `${newLeft}px`;
      /** @type {HTMLElement} */
      const caret = panel.querySelector(".caret");
      caret.style.left = `${newCaretOffset}px`;
    }

    // As it's a dialog, we trap focus.
    // TODO: when <dialog> becomes a imple