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

Ensure to close visitor popover correctly #15443

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions plugins/Live/javascripts/visitorProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,27 @@
var self = this,
$element = this.$element;

$element.on('click', '.visitor-profile-close', function (e) {
e.preventDefault();
try {
$element.tooltip('destroy');
} catch (e) {}
broadcast.propagateNewPopoverParameter(false);
return false;
});
// if there are no popover params in stack, simply close the popover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested this one... but not quite understanding the logic... Eg I would have expected that when there is a popoverParamStack then we call the Popover.close? Or is the popover not added to the stack in that case? When is a popover added to the stack? I'm looking at the code for popover etc and it all looks a bit complicated to understand easily.

I would have maybe expected also some check if the profile is shown within a popover or not? like self.$element.closest('#Piwik_Popover').length or do we always show it within a popover so far?

Is popoverParamStack basically used when the popover is opened through the hash in the URL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stack is modified when broadcast.propagateNewPopoverParameter is called and not when a popover is opened directly. When the method is called with a new popover parameter it's added to the stack. When the method is called with false, the last stack entry should be removed and the url hash will be updated to the next popover in stack or removed.

if (!broadcast.popoverParamStack.length) {
$element.on('click', '.visitor-profile-close', function (e) {
e.preventDefault();
try {
$element.tooltip('destroy');
} catch (e) {
}
Piwik_Popover.close();
});
} else {
$element.on('click', '.visitor-profile-close', function (e) {
e.preventDefault();
try {
$element.tooltip('destroy');
} catch (e) {
}
broadcast.propagateNewPopoverParameter(false);
return false;
});
}

$element.on('click', '.visitor-profile-toggle-actions', function (e) {
e.preventDefault();
Expand Down