danielepiccone / ng-pageslide

AngularJS sliding panel for serving additional content from off the page
http://danielepiccone.github.io/ng-pageslide/examples/
452 stars 162 forks source link

Page slide closing on a unrelated button click #151

Closed thiagokokada closed 7 years ago

thiagokokada commented 7 years ago

I have the following using pageslide:

<pageslide ps-open="$parent.showSearchPanel" ps-side="left" ps-auto-close="0" class="search-panel">
<!--- ... --->
        <div ng-repeat="searchEntry in searchEntries[field.fieldKey]">
            <button
                uib-tooltip="{{
                    (texts.search.filter ? texts.search.filter : 'Filter') + ': ' + searchEntry.filter.name + '\n' +
                    (texts.search.search ? texts.search.search: 'Search') + ': ' + searchEntry.input
                }}"
                tooltip-placement="top"
                tooltip-trigger"'mouseenter'"
                tooltip-enable="true"
                ng-click="deleteSearch($index, field)" 
                class="btn btn-danger"
                style="padding: 1px; margin-bottom: 3px;">
                {{searchEntry.input}}
                <span class="fa fa-trash"></span>
            </button>
        </div>
<!--- ... --->
</pageslide>

And this is the on click function associated with those buttons (as you can see, it doesn't modify the variable that psOpen is monitoring):

            scope.deleteSearch = function(index, field) {
                scope.searchEntries[field.fieldKey].splice(index, 1);
                console.log(scope.searchEntries);
            };

When I click in any button generated with the ng-repeat, pageslide closes. I have other buttons in the same pageslide that does not trigger this issue, only in those ones listed in the code. This seems really strange, any hint what may be the issue here?

thiagokokada commented 7 years ago

I put a datepicker popup from angular-ui. When I select a date, I have the same issue (pageslide closes). Pressing today/clear/close button does not trigger the issue.

thiagokokada commented 7 years ago

Adding ps-click-outside="false" seems to solve the issue, however this is not really what I want. Any tips?

thiagokokada commented 7 years ago

Made a Plunkr showing the problem: https://plnkr.co/edit/9lfwhCpOmzyh4r4fKCgI

Hope it helps.

danielepiccone commented 7 years ago

Thanks for reporting, I expect the problem to behttps://github.com/dpiccone/ng-pageslide/blob/master/src/angular-pageslide-directive.js#L315 since the autoClose param is not initialized properly. It should be moved at line 51 and sanitized properly.

Hope this helps for the moment, will make the fix and release a new version in the next days

danielepiccone commented 7 years ago

Well, apart from that, and your plunker helped a lot :+1: , I discovered that onBodyClick was closing the pageslide since by the time you clicked on the date, the button was removed from the DOM and so !slider.contains(target) was returning true.

I am adding an extra check so that the element should belong to the body as well.