message: Remove document click event listener on finalize.
  Fixes
diff: @@ -335,6 +335,8 @@ async function _embed(
  await view.initialize(el).runAsync();
  + let documentClickHandler: ((this: Document, ev: MouseEvent) => void) | undefined;
  +
  if (actions !== false) {
  let wrapper = div;
  @@ -349,11 +351,12 @@ async function _embed(
  details.append(summary);
  - document.addEventListener('click', evt => {
  - if (!details.contains(evt.target as any)) {
  + documentClickHandler = (ev: MouseEvent) => {
  + if (!details.contains(ev.target as any)) {
  details.removeAttribute('open');
  }
  - });
  + };
  + document.addEventListener('click', documentClickHandler);
  }
  const ctrl = document.createElement('div');
  @@ -437,5 +440,15 @@ async function _embed(
  }
  }
  + // Wrap view.finalize to also remove event listeners from Vega-Embed.
  + if (documentClickHandler) {
  + const originalFinalize = view.finalize.bind(view);
  + view.finalize = () => {
  + document.removeEventListener('click', documentClickHandler!);
  +
  + originalFinalize();
  + };
  + }
  +
  return { view, spec, vgSpec };
  }
  