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

Modal pointer events #22493

Closed
colltoaction opened this issue Apr 21, 2017 · 6 comments
Closed

Modal pointer events #22493

colltoaction opened this issue Apr 21, 2017 · 6 comments

Comments

@colltoaction
Copy link

I'd like to suggest adding pointer events to the Modal component.

The addition would be something similar to:

.modal {
    pointer-events: none;

    .modal-dialog {
        pointer-events: auto;
    }
}

The idea is to allow click events to fall through to the modal-backdrop, which is covered by modal. This is very important to allow people not using the JS library to build on top of Bootstrap.

In my case, I'm using Angular and without that bit I can't bind a click handler to close the modal when tapping the backdrop:

<div class="modal fade show">
    <div class="modal-dialog" role="document">
        <!-- content -->
    </div>
</div>
<div class="modal-backdrop fade show" *ngIf="show" (click)="closeModal()"></div>

Thanks!

@patrickhlauke
Copy link
Member

You'd probably even want to go a step further and use

.modal {
    pointer-events: none;

    .modal-content {
        pointer-events: auto;
    }
}

.modal-content rather than .modal-dialog

@colltoaction
Copy link
Author

Just realized your suggestion doesn't scroll. I'm using modal-dialog instead of modal now:

.modal-dialog {
    pointer-events: none;

    .modal-content {
        pointer-events: auto;
    }
}

@mdo
Copy link
Member

mdo commented May 26, 2017

Can't do this if it disables scrolling. If there's another way, I'm happy to hear it, otherwise we probably have to close this as a won't fix.

@patrickhlauke
Copy link
Member

Can't do this if it disables scrolling.

that was just my original suggestion (which I hadn't tested). @tinchou's code above does seem to work just fine in terms of not suppressing scrolling...incoming PR

@patrickhlauke
Copy link
Member

confirmed that it doesn't prevent scrolling in iOS/Safari nor Chrome/Android. seems safe...

@mdo mdo modified the milestones: v4.0.0-beta, v4.0.0-beta.2 May 26, 2017
@mdo mdo added the has-pr label May 26, 2017
@mdo mdo removed this from the v4.0.0-beta.2 milestone Jun 18, 2017
@mdo mdo mentioned this issue Aug 22, 2017
@aldencolerain
Copy link

@patrickhlauke It looks to me like pointer events should be disabled on modal not modal-dialog. Am I missing something? I had to move disabling pointer events up a level for this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants