Skip to content

Apply style dialog edits on Save and ask before discarding them - #2703

Open
kmcginnes wants to merge 4 commits into
mainfrom
style-dialogs-save-cancel
Open

kmcginnes wants to merge 4 commits into
mainfrom
style-dialogs-save-cancel

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Summary

The node and edge style dialogs wrote every edit to the stored styles as you made it, so each keystroke and each pause in a color drag restyled the graph, and there was no way to back out of a change.

User-facing: Style dialog edits now apply when you click Save, and the preview shows them first. Cancel throws them away. Escape, the close button, or a click outside the dialog asks "Discard Unsaved Changes?" when there are unsaved edits. Clear Customization is now Reset to Default, which fills the dialog with the default style until you save.

NodeStyleDialog / EdgeStyleDialog
  useAppForm(draft opened from the stored style)
    fields → draft only, preview reads the draft
    Save   → saveVertexStyle / saveEdgeStyle (one write)
    Cancel → close
    Escape, ×, outside click
      draft unchanged → close
      draft changed   → DiscardChangesDialog
 useVertexStyling(type) / useEdgeStyling(type)
   vertexStyle, setVertexStyle
-  resetVertexStyle
+  saveVertexStyle(draft)   // stores fields that differ from the default,
+                           // keeps fields the dialog doesn't edit, deletes an empty entry

The forms use the components/form parts, with three new ones: field.NumberInput, field.ColorPopover, and field.Select. Numbers are checked against a Zod schema when you click Save, with the error under the field.

Evidence

Before: every edit in the dialog wrote the stored styles right away. One session that changed opacity, border width, and one color wrote them 7 times, and Graph View restyled after each write.

After: the same session writes once, on Save. Cancel writes nothing.

The dialog with unsaved edits, the preview showing them, and Save enabled:

The node style dialog with unsaved edits

Closing it with unsaved edits:

The discard confirmation

Verified live: both dialogs in Chromium and Safari against the dev server, with a seeded sample connection:

  • Save, Cancel, Reset to Default followed by Save, and icon Browse and Upload.
  • The discard prompt on Escape, the close button, and an outside click.
  • Out-of-range numbers.
  • A picked color stored on Save in every run (11 of 11).

Merge Danger

Door: two-way. The stored style shape is unchanged, so older builds still read anything this one saves.

Impact: behavior. Edits stop applying until Save. See Upgrade Notes.

Upgrade Notes

  • Style dialog edits apply on Save. Click Save to keep your changes. Escape, the close button, or a click outside the dialog now asks before it discards unsaved edits, where it used to keep them.
  • Clear Customization is now Reset to Default. It fills the dialog with the default style. Click Save to clear the type's customization. The type's display label stays.
  • Saving drops values that equal the default. When you save a type in the dialog, any setting that matches the app default is no longer stored, so a later change to that default applies to the type too.

Related


🤖 Written by an AI agent on my behalf.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant