Git Product home page Git Product logo

Comments (3)

joshua-dean avatar joshua-dean commented on August 19, 2024 1

So if I'm understanding the logic correctly - every submit button has a optional set_saved entry. If provided, on pressing the submit button ULabel's edited value gets updated to the value of set_saved, effectively giving each button the power to fully invalidate or validate the edited state, correct?

Is there ever a case where it's useful for a submit button to set edited to false, forcing the prompt? I'd argue set_saved should be a binary rather than an optional binary: it either sets the value to true or does nothing (defaulting to false rather than null).

from ulabel.

TrevorBurgoyne avatar TrevorBurgoyne commented on August 19, 2024

As of #135 a set_saved argument is available for custom submit buttons, this is what I have been using to avoid the beforeunload warning on custom submit navigation logic

from ulabel.

TrevorBurgoyne avatar TrevorBurgoyne commented on August 19, 2024

So if I'm understanding the logic correctly - every submit button has a optional set_saved entry. If provided, on pressing the submit button ULabel's edited value gets updated to the value of set_saved, effectively giving each button the power to fully invalidate or validate the edited state, correct?

Is there ever a case where it's useful for a submit button to set edited to false, forcing the prompt? I'd argue set_saved should be a binary rather than an optional binary: it either sets the value to true or does nothing (defaulting to false rather than null).

A reminder that set_saved is the opposite of the edited state:

  • set_saved(true) will set edited to false
  • set_saved(false) will set edited to true

The unload warning occurs when edited state is true

If the button arg set_saved defaults to false, then in the case where no edits are made and then a submit button is pressed, the unload warning will appear bc the button itself is marking the edited state as true. So I agree that I honestly don't see a use case for setting edited to true on button click.

So as is, we can technically achieve three kinds of behavior:

  • set_saved: true will NEVER show the unload warning when submitting
  • set_saved: false will ALWAYS show the unload waning when submitting
  • set_saved: null will show the unload warning when submitting only if something was edited

To go from optional binary to binary, we'd want to change set_saved: false to be the default, while also changing its behavior to be that of set_saved: null. So we lose the ability to ALWAYS show the unload warning, which i agree is useless anyways.

TL;DR the switch from optional binary to binary would eliminate one of the three current options, which also happens to be practically useless anyways 🤷

from ulabel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.