owid-grapher icon indicating copy to clipboard operation
owid-grapher copied to clipboard

Static SVGs shouldn't contain <foreignObject>s

Open danielgavrilov opened this issue 2 years ago • 4 comments

Description

Static SVGs seem to contain <foreignObject>, even though nothing is rendered inside of one (I think?)

Expected behaviour

Any <foreignObject> should be excluded from static SVGs.

Examples

  • https://ourworldindata.org/grapher/exports/share-of-land-covered-by-lakes-and-rivers.svg

danielgavrilov avatar Apr 25 '22 11:04 danielgavrilov

Probably the fix is to check isExportingtoSvgOrPng is false before a <foreignObject> is embeded.

danielgavrilov avatar Apr 25 '22 11:04 danielgavrilov

Prioritising as important since these are the potential cause for some broken SVGs in the SVG tester, and should be very easy to fix.

The <foreignObject> contents appear truncated for some reason (see here): Screenshot 2022-04-25 at 13 17 21

danielgavrilov avatar Apr 25 '22 11:04 danielgavrilov

Ah, once that is fixed we can probably also remove some special code handling react-select ids from the svgTester: https://github.com/owid/owid-grapher/blob/073a087f936f0fc14f80540d2b663d517f030906/devTools/svgTester/utils.ts#L275

marcelgerber avatar May 01 '22 09:05 marcelgerber

Downgrading to nice to have, happy for someone to pick it up during cooldown.

larsyencken avatar Jul 26 '22 11:07 larsyencken

This problem is basically done now - the NoDataModal is the only thing that still comes up when you search our current svg tester repo for foreginObject. We could fix that too at some point but that is more for convenience

danyx23 avatar Jan 10 '23 16:01 danyx23