Skip to content

[Bug] draw.io diagrams saved in light mode even when app is in dark mode #476

Open

Description

@neov5

draw.io diagrams are saved by default in light mode. This leads to them showing black text on a black background, like the following:

Screenshot 2024-11-08 at 11 59 51 PM

some poking around the codebase led me to this block of code:

onSave={(data: EventSave) => {
  // If the save is triggered by another event, then do nothing
  if (data.parentEvent !== 'save') {
    return;
  }
  handleSave(data);
}}

onSave is exposed by react-drawio, which does this on save:

save: (data) => {
  action.exportDiagram({
    format: exportFormat || 'xmlsvg',
    // @ts-ignore not allowed normally, but only for internal use
    exit: data.exit,
    parentEvent: 'save'
  });
},

A possible fix is to bundle a version of react-drawio with the extra parameter keepTheme: true in this save callback, to retain the theme when saving. Other workarounds might include some callback magic but no obvious solutions are apparent to me after skimming the code.

Activity

  1. neov5 commented on Nov 8, 2024

    @neov5
    Author

    react-drawio also has this issue opened recently about exposing these options as props, so maybe if a fix for that gets merged using it would be easier

  2. Philipinho commented on Nov 11, 2024

    @Philipinho
    Member

    If we set keepTheme to true, won't light mode users complain of the same thing?
    In the case of Excalidraw, I have resorted to saving the diagrams in light mode.

    Since the finalized diagram is saved to the file storage, I think it is impossible to satisfy both theme options.

  3. neov5 commented on Nov 11, 2024

    @neov5
    Author

    You're right that it's impossible to satisfy both theme options, but you can have light mode users' diagrams saved in light mode and dark mode users' saved in dark mode because we set the draw.io theme depending on the current docmost theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions