GithubHelp home page GithubHelp logo

Comments (5)

frankieroberto avatar frankieroberto commented on September 13, 2024

Previously reported here: #203

from govuk-formbuilder.

peteryates avatar peteryates commented on September 13, 2024

Thanks @frankieroberto - I'm keen for this to remain in the form builder as that's where most people would expect to find it. As it's actually causing problems that affect users it'll definitely be resolved - I'm not totally sure of the best way yet, but it'll probably be either:

  • a #govuk_submit_button helper on the builder that renders a button
  • an argument (with corresponding config to set the default) that can be supplied to the existing #govuk_submit, which toggles between input and button

I'd assume that if we're rendering a <button> element we'd want to be able to provide its contents with a block of HTML in addition to a string, and #govuk_submit already uses its block to wrap itself in a button group, so maybe the former would make more sense.

from govuk-formbuilder.

peteryates avatar peteryates commented on September 13, 2024

I had a really quick play with the idea and think it might be the way forward.

Adding a button: param to #govuk_submit that defaults to the configuration's default setting - true to always render buttons by default and false to use inputs.

This allows buttons to be configured by the developer if one or the other is needed for a odd circumstance.

Also, the button arg could take a proc (as seen elsewhere in the library), that would allow the contents of the <button> element to be set with any arbitrary HTML.

Unless I've missed something here it feels like a sensible approach that'll work for most people. I'm hesitant to just switch over from input to button en masse as it'll mean people will need to update their tests.

from govuk-formbuilder.

frankieroberto avatar frankieroberto commented on September 13, 2024

Happy to keep it in the formbuilder, although I think it’d be good to make it available outside of a formbuilder as a global helper too, given that it doesn’t need to bind to the form model.

I don't think we have any reason to also support the <input type="submit">, especially with that bug.

Given how prevalent form buttons are, it might be sensible to think through how to enable users to switch to the button in the least painful way.

Options could be:

  1. make govuk_submit output a button, but do this in a major version release as it might break some existing tests which expect an input. However this might require the least downstream changes.
  2. create a new govuk_button or govuk_submit_button method and/or helper.
  3. mark govuk_submit as deprecated for a version.

Agree with supporting block content as well as a string. One of the advantages of the <button> element is that it can support additional markup (although it's rarely needed).

We should also make sure that both the button and the link-styled-as-button support both the prevent-double-click option and start-button option – and that both include the data-module="govuk-button" attribute.

from govuk-formbuilder.

frankieroberto avatar frankieroberto commented on September 13, 2024

If people are using the capybara method click_button in their tests, then that shouldn’t require any code changes, as that already supports both <input type="button"> and <button>.

from govuk-formbuilder.

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.