Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(modal): fix for conflicts with ngTouch module on mobile devices #3044

Merged
merged 1 commit into from
Jan 8, 2015
Merged

fix(modal): fix for conflicts with ngTouch module on mobile devices #3044

merged 1 commit into from
Jan 8, 2015

Conversation

jiniguez
Copy link
Contributor

@jiniguez jiniguez commented Dec 3, 2014

This change attempts to fix issue #2280

ng-click directive has been removed from modal template and click event moved to the modal-window directive code, so the click event keeps firing and modal window closes when clicking on the backdrop. Not sure if there's a better place to put this event but the fix seems to be working.

@aktary
Copy link

aktary commented Jan 6, 2015

Thank you for this solution! This solved my problem. When is it going to be merged??

@karianna karianna added this to the 0.13 milestone Jan 8, 2015
karianna added a commit that referenced this pull request Jan 8, 2015
fix(modal): fix for conflicts with ngTouch module on mobile devices
@karianna karianna merged commit f671e02 into angular-ui:master Jan 8, 2015
@tomasreichmann
Copy link

Hi guys, sorry, for such a noob question:
Is it possible to download a production ready minified version of ui-bootstrap-tpls-0.12.#.min with this fix included? Ideally a link or CDN.

Thanks

@karianna
Copy link
Contributor

karianna commented Jan 8, 2015

Not that I'm aware of sorry (I'm new here myself)

@jiniguez jiniguez deleted the fix2280 branch January 10, 2015 14:30
@karianna
Copy link
Contributor

@chrisirhc - This was the other PR I merged without cherry picking - shall I revert and add a REady to Merge label?

chrisirhc added a commit that referenced this pull request Feb 20, 2015
This reverts commit f671e02, reversing
changes made to eec68d8.
@adamreisnz
Copy link

Has this change been reverted again? When I download the latest version (0.13.0), looking in the template code for modals, I find ng-click=\"close($event)\"> is back.

This is still causing issues when ngTouch is enabled.

@dubejf
Copy link

dubejf commented May 15, 2015

Yes, the merge was reverted by @chrisirhc. Why?

@chrisirhc
Copy link
Contributor

Sorry, I reverted it initially because it didn't follow our merging guidelines. And I believe we forgot about re-applying the change since then. Reopening #2280 to avoid confusion.

@philefstat
Copy link

Looking forward to this fix being re-merged at some point...

@piotrd
Copy link

piotrd commented Jul 2, 2015

Looking forward to this fix being re-merged at some point...

👍

@twhamilton
Copy link

+1 Please !

@khoacoi
Copy link

khoacoi commented Jul 27, 2015

  • 1 please

@khoacoi
Copy link

khoacoi commented Aug 20, 2015

Hi,

Is there any update when this change can be merged? Is there any work around solution to fix this issue?

Thanks,

@twhamilton
Copy link

The fix is in one of the links above.

This is what I did..

in ui-boostrap-tpls.js
//***********************************************
// REMOVED ng-click="close($event)" to fix issue #2280
// #2280
//*******************************************************************************************
angular.module("template/modal/window.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("template/modal/window.html",
"<div modal-render="{{$isRendered}}" tabindex="-1" role="dialog" class="modal"\n" +
" modal-animation-class="fade"\n" +
" modal-in-class="in"\n" +
" ng-style="{'z-index': 1050 + index*10, display: 'block'}">\n" +
" <div class="modal-dialog" ng-class="size ? 'modal-' + size : ''"><div class="modal-content" modal-transclude>\n" +
"\n" +
"");
}]);

/* THIS WAS THE ORIGINAL
angular.module("template/modal/window.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("template/modal/window.html",
"<div modal-render="{{$isRendered}}" tabindex="-1" role="dialog" class="modal"\n" +
" modal-animation-class="fade"\n" +
" modal-in-class="in"\n" +
" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)">\n" +
" <div class="modal-dialog" ng-class="size ? 'modal-' + size : ''"><div class="modal-content" modal-transclude>\n" +
"\n" +
"");
}]);
*/

Then in ui-boostrap.js added the element.on function

.directive('modalWindow', [
'$modalStack', '$q', '$animate',
function ($modalStack , $q , $animate) {
return {
restrict: 'EA',
scope: {
index: '@'
},
replace: true,
transclude: true,
templateUrl: function(tElement, tAttrs) {
return tAttrs.templateUrl || 'template/modal/window.html';
},
link: function (scope, element, attrs) {
element.addClass(attrs.windowClass || '');
scope.size = attrs.size;

    //****************************** 
    // moved from template to fix issue #2280
    // https://github.com/angular-ui/bootstrap/issues/2280
    //*******************************************
    element.on('click', function(evt) {
      scope.close(evt);
    });

    scope.close = function (evt) {
      var modal = $modalStack.getTop();
      if (modal && modal.value.backdrop && modal.value.backdrop != 'static' && (evt.target === evt.currentTarget)) {
        evt.preventDefault();
        evt.stopPropagation();
        $modalStack.dismiss(modal.key, 'backdrop click');
      }
    };

@mastef
Copy link

mastef commented Sep 7, 2015

@chrisirhc Anything specific that was wrong in the PR? Would love to resubmit PR to have this implemented. Could you point at the right direction what was wrong with the PR?

@icfantv
Copy link
Contributor

icfantv commented Sep 7, 2015

@mastef, I don't think there'll be any issues, but given the age of this, please rebase and ensure your code is fully up-to-date and that this PR would still have no conflicts.

additionally, we've since implemented a CI build that will get kicked off when you submit a PR that was clearly instituted after you submitted this originally. I don't know that we'll require it given the nature of this change, but it might be nice just for sanity sake. @wesleycho, would you have any hesitations merging this as is or if you had other stipulations, what would they be?

@chrisirhc
Copy link
Contributor

I don't think there were any issues (besides lack of tests, but I'm not sure how to test, and that shouldn't block it), it just needs to be re-cherry-picked into the code.

@wesleycho
Copy link
Contributor

I'm still a bit baffled why this fixes the issue, but I fon't have any particular objections if it works

@chrisirhc
Copy link
Contributor

I believe it's because ngTouch adds an ngClick directive that attempts to be smart about detecting where you're tapping. However, in this case, it incorrectly detects tapping on the modal while it should instead tap into elements within the modal.

chrisirhc pushed a commit to chrisirhc/angular-ui-bootstrap that referenced this pull request Sep 7, 2015
- Merge pull request angular-ui#3044 from jiniguez/fix2280
Conflicts:
	src/modal/modal.js
	template/modal/window.html

Fixes angular-ui#2280
chrisirhc pushed a commit to chrisirhc/angular-ui-bootstrap that referenced this pull request Sep 7, 2015
- Merge pull request angular-ui#3044 from jiniguez/fix2280
Conflicts:
	src/modal/modal.js
	template/modal/window.html

Fixes angular-ui#2280
chrisirhc pushed a commit that referenced this pull request Sep 7, 2015
- Merge pull request #3044 from jiniguez/fix2280
Conflicts:
	src/modal/modal.js
	template/modal/window.html

Fixes #2280
Closes #4357
jasonaden pushed a commit to deskfed/bootstrap that referenced this pull request Jan 8, 2016
- Merge pull request angular-ui#3044 from jiniguez/fix2280
Conflicts:
	src/modal/modal.js
	template/modal/window.html

Fixes angular-ui#2280
Closes angular-ui#4357
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.