Skip to content

Commit

Permalink
Merge pull request #14436 from jdalsem/elgg5-minor
Browse files Browse the repository at this point in the history
fix(views): do not use rel to track related hover menu placeholders
  • Loading branch information
jeabakker committed Jul 20, 2023
2 parents 779f5e0 + 972f408 commit d5c059a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions views/default/icon/user/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define(['jquery'], function ($) {
* @param {Function} callback a callback function to call when the loading of het menu was succesfull
*/
function loadMenu(mac, callback) {
var $all_placeholders = $(".elgg-menu-hover[rel='" + mac + "']");
var $all_placeholders = $(".elgg-menu-hover[data-menu-id='" + mac + "']");

if (!$all_placeholders.length) {
return;
Expand All @@ -31,7 +31,7 @@ define(['jquery'], function ($) {
}
},
complete: function() {
$all_placeholders.removeAttr('data-menu-placeholder data-elgg-menu-data');
$all_placeholders.removeAttr('data-menu-id data-elgg-menu-data');
}
});
});
Expand Down Expand Up @@ -72,10 +72,10 @@ define(['jquery'], function ($) {

var $icon = $(this);

var $placeholder = $icon.parent().find('.elgg-menu-hover[data-menu-placeholder]');
var $placeholder = $icon.parent().find('.elgg-menu-hover[data-menu-id]');

if ($placeholder.length) {
loadMenu($placeholder.attr('rel'), function() {
loadMenu($placeholder.attr('data-menu-id'), function() {
showPopup($icon);
});
} else {
Expand Down
11 changes: 5 additions & 6 deletions views/default/navigation/menu/user_hover/placeholder.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

$user = elgg_extract('entity', $vars);
if (!$user instanceof ElggUser) {
if (!$user instanceof \ElggUser) {
return;
}

$guid = (int) $user->guid;
$page_owner_guid = (int) elgg_get_page_owner_guid();
$guid = $user->guid;
$page_owner_guid = elgg_get_page_owner_guid();
$contexts = elgg_get_context_stack();
$input = (array) elgg_get_config('input');

Expand All @@ -15,9 +15,8 @@
$mac = elgg_build_hmac($data)->getToken();

echo elgg_format_element('ul', [
'rel' => $mac,
'class' => 'elgg-menu elgg-menu-hover',
'data-menu-placeholder' => '1', // flag for the JS to know this menu isn't fully loaded yet
'class' => ['elgg-menu', 'elgg-menu-hover'],
'data-menu-id' => $mac,
'data-elgg-menu-data' => json_encode([
'g' => $guid,
'pog' => $page_owner_guid,
Expand Down

0 comments on commit d5c059a

Please sign in to comment.