framework7io / framework7

Full featured HTML framework for building iOS & Android apps
http://framework7.io
MIT License
18.04k stars 3.23k forks source link

Add disabled/rule to parent class of disabled element in action sheet #4138

Open Simone4e opened 1 year ago

Simone4e commented 1 year ago

Describe the bug

The problem is that when the button is disabled it should add a class to its parent as well so that you can add cursor: not-allowed to the parent and leave pointer-events:none as it already is in the system

To Reproduce

Steps to reproduce the behavior:

  1. Go to codesanbox
  2. Click on press me
  3. See cursor is normal instead of not-allowed as should be

Expected behavior

If you add :has like this:

li:has(> .disabled) {
  cursor: not-allowed;
}

You will see the correct result, but it must be said that :has is not yet fully compatible, so I would add an additional class for these cases


At the moment I decided to use this solution:

var app = new Framework7({
....

actions: {
        on: {
            open: function () {
                if (this.$el[0].classList.contains('popover')) {
                    this.$el[0].querySelectorAll('a.disabled').forEach(el => {
                        el.parentElement.classList.add('disabledCursor');
                    });
                }
            }
        }
    },
.....

In css:

.disabledCursor{
    cursor: not-allowed !important;
}

By doing so I add a class to the parent automatically.