magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Modal UI: clickableOverlay option doesn't work #7399

Closed thdoan closed 5 years ago

thdoan commented 8 years ago

Preconditions

  1. Magento 2.1.2

Steps to reproduce

  1. Go into any template and create a modal widget with this code:
require(['Magento_Ui/js/modal/modal'], function(modal) {
  $('#some-element').click(function(e) {
    e.preventDefault();
    $('<p>Overlay content</p>').modal().modal('openModal');
  });
});
  1. Click on $('#some-element') to show the overlay.
  2. Click on the overlay (shadow).

Expected result

  1. According to the documentation, the default clickableOverlay value is true, which means "Close the modal window when a user clicks on the overlay".

Actual result

  1. Nothing happens (i.e., the overlay does not close). Even when you manually specify the option, it doesn't work:

$('<p>Overlay content</p>').modal({ clickableOverlay: true }).modal('openModal');

BB-000 commented 8 years ago

+1 , The z-index of the popup is higher than the .modals-overlay, but the popup wrapper

erikhansen commented 7 years ago

I've encountered this issue on multiple projects.

erikhansen commented 7 years ago

We created a workaround for this issue in a custom theme using a RequireJS mixin by adding the following files:

app/design/frontend/<VENDOR>/<THEME>/Magento_Ui/web/js/model/modal-mixin.js

define([
    'jquery',
    'mage/utils/wrapper'
], function ($, wrapper) {
    'use strict';

    return function (modal) {

        modal.prototype.openModal = wrapper.wrap(modal.prototype.openModal, function(original) {

            var result = original();
            $('.' + this.options.overlayClass).appendTo('.modal-popup._show');
            //Setting z-index of inner-wrap to 900 so that it is actually clickable and not hiding behind the overlay
            $('.modal-inner-wrap').css('z-index', 900);
            return result;
        });

        return modal;
    };
});

app/design/frontend/<VENDOR>/<THEME>/requirejs-config.js

var config = {
    config: {
        mixins: {
            'Magento_Ui/js/modal/modal': {
                'Magento_Ui/js/model/modal-mixin': true
            }
        }
    }
};

See this great article by Alan Storm for info on M2's RequireJS Mixins: http://alanstorm.com/the-curious-case-of-magento-2-mixins/

miakusha commented 7 years ago

Hi @thdoan thanks for report We've created internal ticket MAGETWO-63410 to address this issue.

BB-000 commented 7 years ago

@erikhansen Unfortunately for me that fix works on desktop (popup) but breaks mobile (slide) modals...

erikhansen commented 7 years ago

@BB-000 Yeah, we discovered some issues with the code I posted previously and have since refactored and moved the code into a standalone extension called ClassyLlama_ModalEnhancements. I've attached it to this comment. Use at your own risk.

ClassyLlama_ModalEnhancements.zip

nntoan commented 7 years ago

@erikhansen It's working. Please create a PR :)

magento-engcom-team commented 7 years ago

@thdoan, thank you for your report. We've created internal ticket(s) MAGETWO-63410 to track progress on the issue.

mak0605 commented 6 years ago

Hello I am looking for this issue #mm18in

magento-engcom-team commented 6 years ago

@mak0605 thank you for joining. Please accept team invitation here and self-assign the issue.

SimonAnguish commented 6 years ago

I have a quick solution for this. In a custom css file, you can add bottom: initial and overflow-y: inherit !important (or increase the specificity) to the .modal-popup class. This causes the modal to only cover the top line of the screen, but the content still shows.

alpacode-pmakowski commented 6 years ago

distributed-cd hello, i am going take a look if can help a bit with that.

magento-engcom-team commented 6 years ago

@virtua-pmakowski thank you for joining. Please accept team invitation here and self-assign the issue.

magento-engcom-team commented 6 years ago

Hi @thdoan. Thank you for your report. The issue has been fixed in magento/magento2#15172 by @virtua-pmakowski in 2.2-develop branch Related commit(s):

The fix will be available with the upcoming 2.2.5 release.

shibinvr commented 6 years ago

hi when upgrade with ClassyLlama_ModalEnhancements.zip module but still modal not close when click overlay. any idea why

sidolov commented 6 years ago

Hi @thdoan. Thank you for your report. The issue has been fixed in magento/magento2#16665 by @mageprince in 2.1-develop branch Related commit(s):

The fix will be available with the upcoming 2.1.15 release.

sidolov commented 6 years ago

Hi @thdoan. Thank you for your report. The issue has been fixed in magento/magento2#16664 by @mageprince in 2.3-develop branch Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

hamdrew commented 6 years ago

I do not see this fix in the Magento 2.2.5 release

BB-000 commented 5 years ago

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

zaximus84 commented 5 years ago

This is not fixed in 2.2. The CSS for pointer-events is present, but modal.js doesn't actually handle a click on the overlay. clickableOverlay is present in the default options, but it's not found anywhere else in the file (meaning it's not used). Comparing 2.1, 2.2, and 2.3, the _createOverlay method is lacking lines in 2.2.

m2-assistant[bot] commented 5 years ago

Hi @engcom-Charlie. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Charlie commented 5 years ago

Hello @zaximus84 Branch 2.2-develop was closed and Magento no longer accepts pull requests and issues to the v2.2 release lines to focus all development efforts on v2.3._ See Accepted pull requests and ported code for more details So i close this issue.

LiamKarlMitchell commented 4 years ago

Still a problem in Magento 2.3.0

sarkadiadam commented 4 years ago

Hello, made it work by applying a small css fix (if anyone is still interested):

.modal-popup {
    pointer-events: none;
    touch-action: none;
}