question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There is no clear way to disable a button

See original GitHub issue

I have a form with button and when submitting the form I’ll like to disable all the components because there might be an error return from the server in which can I’ll re-enable the components to allow the user to correct the input and submit it again.

Currently I don’t see any way to disable to button except of removing the onClick which does not seem like the right way.

Expected Behavior

I think it will be better to have the disabled attribute be settable so we could disable the button.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, Jun 5, 2017

I bow before the HOR (higher order reason) that prevents the Button component to have a simple disabled property, but for everyone that isn’t that enlightend in UX philosopy, the following wrapper might come in handy:

import React from 'react'
import Button from 'grommet/components/Button'
import _ from 'underscore'

export default (props) => {
    const newProps = props.disabled ? Object.assign({}, _.omit(props, 'onClick')) : props
    return (
        <Button {...newProps} />
    )
}
2reactions
tracybarmorecommented, Jan 10, 2017

Hi @ido-ran, Grommet has a showcase app that uses a pattern for a processing/validating state of a form.

  • Go to http://ferret.grommet.io/settings/edit
  • Click ‘Connect’ next to Directory
  • Type in anything in Directory Server input field, Click Connect
  • Button is replaced by spinner and verb of action

bitmap

Let us know if this answers your question and if we can close this issue. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable/Disable Clear button based on the search criteria
Enable/Disable Clear button based on the search criteria · 1 - First the clear button will be disabled · 2 - When the...
Read more >
How to disable or enable buttons using Javascript and jQuery
Learn how to enable or disable buttons using javascript and jQuery based on whether the input field is filled or empty.
Read more >
Why You Shouldn't Gray Out Disabled Buttons - UX Movement
How should disabled buttons appear when they're inactive? The way most designers indicate an inactive state is by graying out the button.
Read more >
Frustrating Design Patterns: Disabled Buttons
As Adam Silver notes in his excellent book “Form Design Patterns”, usually disabled buttons are not focusable and hence users can't reach them ......
Read more >
Disabled Buttons in User Interface - Nick Babich
It is still possible to disable a submit button by default for login, shipping, billing, and many other forms when all fields are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found