Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cursor: not-allowed isn't working on disabled buttons #16088

Closed
pedroleo opened this issue Mar 17, 2015 · 12 comments · Fixed by #16092
Closed

cursor: not-allowed isn't working on disabled buttons #16088

pedroleo opened this issue Mar 17, 2015 · 12 comments · Fixed by #16092

Comments

@pedroleo
Copy link

Sorry for open another issue for a already closed subject, but I'm not pretty sure if it's a expected behavior.

At the newest bootstrap library, we can find this rule:

"
.btn.disabled, .btn[disabled], fieldset[disabled] .btn {
pointer-events: none;
cursor: not-allowed;
filter: alpha(opacity=65);
-webkit-box-shadow: none;
box-shadow: none;
opacity: .65;
}
"

So I assume that bootstrap tried to implement the cursor: not-allowed for disabled buttons, or input's.

I have created two jsfiddles. The only diference between both, is that one has the bootstrap-min.css imported and the other don't.

We can see that when I don't import the bootstrap library, everything works fine and when I import, it doesn't work anymore.

jsfiddle with bootstrap imported: https://jsfiddle.net/3sq410wk/
jsfiddle without bootstap css: https://jsfiddle.net/f2t9ahqe/

@twbs-lmvtfy
Copy link

Hi @Ccriativo!

You appear to have posted a live example (https://fiddle.jshell.net/f2t9ahqe/show/light/), which is always a good first step. However, according to the HTML5 validator, your example has some validation errors, which might potentially be causing your issue:

  • line 32, column 78: Attribute text not allowed on element input at this point.
  • line 33, column 89: Attribute text not allowed on element input at this point.

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!

(Please note that this is a fully automated comment.)

@twbs-lmvtfy
Copy link

Hi @Ccriativo!

You appear to have posted a live example (https://fiddle.jshell.net/3sq410wk/show/light/), which is always a good first step. However, according to the HTML5 validator, your example has some validation errors, which might potentially be causing your issue:

  • line 36, column 78: Attribute text not allowed on element input at this point.
  • line 37, column 89: Attribute text not allowed on element input at this point.

You'll need to fix these errors and post a revised example before we can proceed further.
Thanks!

(Please note that this is a fully automated comment.)

@pedroleo pedroleo changed the title Inconsistance Cursos Not Allowed Inconsistance Cursor: Not-Allowed Mar 17, 2015
@pedroleo
Copy link
Author

Sorry about that... it was .Net addiction. =)

With bootstrap: https://jsfiddle.net/3sq410wk/1/
Without bootstrap: https://jsfiddle.net/f2t9ahqe/1/

@patrickhlauke
Copy link
Member

Confirming that the cursor:not-allowed isn't showing correctly. It seems that the preceding pointer-events:none is to blame...once that is removed, the cursor changes correctly (however, we have pointer-events:none as a way to suppress pointer-based activation, in situations where .disabled has been used). /cc @cvrebert

@pedroleo
Copy link
Author

Yes, the pointer-events it's breaking the consistency. It's not the case to remove the cursor:not-allowed then?

Some people are suprised that, in same form elements, we have different behaviors...

@cvrebert
Copy link
Collaborator

X-Ref: #15235

cvrebert added a commit that referenced this issue Mar 17, 2015
<a> doesn't support the `[disabled]` attribute,
so `a.btn.disabled` simulates it using `pointer-events: none`.
However, this is unnecessary for <button>s and <input>s, and
also prevents their `[disabled]` cursor from displaying.

[skip sauce]
[skip validator]
@cvrebert cvrebert changed the title Inconsistance Cursor: Not-Allowed cursor: not-allowed isn't working on disabled buttons Mar 17, 2015
@cvrebert cvrebert added this to the v3.3.5 milestone Jun 16, 2015
@dchacke
Copy link

dchacke commented Jul 28, 2015

For what it's worth, I ended up having to write this to make this work:

button:disabled {
  cursor: not-allowed;
  pointer-events: all !important;
}

@aborchew
Copy link

Came across this thread and thought I'd post my workaround, which I know will not work in all scenarios. For my usage, the a tag was wrapped in an li, and the following allows the usage of both CSS rules at play.

<li class="disabled">
  <a href="#">My Link</a>
</li>
li.disabled {
  cursor: not-allowed;
}
li.disabled a {
  pointer-events: none;
}

In my brief testing, the pre-existing symptoms persist if the rules are swapped (pointer-events on the parent element).

@noum
Copy link

noum commented Aug 5, 2016

It may be useful to disable the pointer-events on .disabled only, and enable it on [disabled]:

.btn.disabled {
  pointer-events: none;
}
.btn.disabled, .btn[disabled], fieldset[disabled] .btn {
  cursor: not-allowed;
}

@mschwenk
Copy link

mschwenk commented Aug 9, 2016

@aborchew thanks, this worked for me.

mybits added a commit to womenhackfornonprofits/ocdaction that referenced this issue Feb 2, 2018
It seems like it'd wider issue in bootstrap, I've used the solution
posted in this thread, not the nicest but the fastest:
twbs/bootstrap#16088
mybits added a commit to womenhackfornonprofits/ocdaction that referenced this issue Feb 3, 2018
It seems like it'd wider issue in bootstrap, I've used the solution
posted in this thread, not the nicest but the fastest:
twbs/bootstrap#16088
@omaracrystal
Copy link

omaracrystal commented Apr 9, 2020

The way I solved it for a custom styled material button was to include the asterisk *

&.mat-button-toggle-disabled {
      cursor: not-allowed;
      color: $disabled-btn-color;

      * {
        cursor: not-allowed;
        color: $disabled-btn-color;
      }
    }

@usmanarain350
Copy link

.pointer-events-none {
    pointer-events: none;
}

.wrapper {
    cursor: not-allowed;
}
<div class="wrapper">
<button class="pointer-events-none">Some Text</button>
</div>

Reference:
#https://stackoverflow.com/questions/46665625/how-to-combine-cursor-not-allowed-and-pointer-events-none

@twbs twbs locked as resolved and limited conversation to collaborators Apr 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants