Skip to content

Commit

Permalink
Privacy settings attach/detach no longer removes link, uses hidden attr.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambient-Impact committed Nov 4, 2023
1 parent 6786029 commit ec3fed1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
19 changes: 12 additions & 7 deletions components/privacy_settings/privacy_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,9 @@ AmbientImpact.addComponent('OmnipediaPrivacySettings', function(
'click.OmnipediaPrivacySettings',
Drupal.eu_cookie_compliance.toggleWithdrawBanner
)
.insertAfter($placeholderLink)
// Save the placeholder link to this button's data so that we can
// restore it on detach.
.data('privacySettingsLink', $placeholderLink);
.insertAfter($placeholderLink);

$placeholderLink.remove();
$placeholderLink.attr('hidden', true);

$toggle = $button;

Expand All @@ -95,11 +92,19 @@ AmbientImpact.addComponent('OmnipediaPrivacySettings', function(
*/
var $button = $('.omnipedia-privacy-settings-toggle', context);

// Restore the previously stored placeholder link.
$button.data('privacySettingsLink').insertAfter($button);
/**
* The privacy settings placeholder link wrapped in a jQuery collection.
*
* @type {jQuery}
*/
var $placeholderLink = $(
'.omnipedia-privacy-settings-placeholder', context
);

$button.remove();

$placeholderLink.removeAttr('hidden');

$toggle = $();

}
Expand Down
5 changes: 4 additions & 1 deletion components/privacy_settings/privacy_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
// in such a way that should minimize or eliminate any layout shifting when the
// swap occurs.
.omnipedia-privacy-settings-placeholder {
display: inline-grid !important;

&:not([hidden]) {
display: inline-grid !important;
}

grid-template-areas: 'content';

Expand Down

0 comments on commit ec3fed1

Please sign in to comment.