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

Bug 1928083 - Bugzilla’s emojis are displayed on the bottom of the page when activated creating a new scroll bar #2351

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions extensions/BugModal/web/bug_modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,6 @@ a.comment-tag-url {
position: relative;
padding: 0 12px 12px;
background: var(--primary-text-background-color);
anchor-name: --comment-reactions;
}

.comment-text.bz_private + .comment-reactions {
Expand Down Expand Up @@ -1322,7 +1321,6 @@ a.comment-tag-url {
transform-origin: bottom left;
transition: all 100ms;
pointer-events: none;
position-anchor: --comment-reactions;
}

.comment-reactions .picker:popover-open {
Expand Down
14 changes: 12 additions & 2 deletions extensions/BugModal/web/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,12 @@ Bugzilla.BugModal.Comments = class Comments {
* @see https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
*/
Bugzilla.BugModal.CommentReactions = class CommentReactions {
/** @type {Boolean} */
canUsePopover = 'popover' in HTMLElement.prototype;
/**
* Check the availability of the Popover API. This also detects the CSS Anchor Positioning API, as positioning doesn’t
* work well without it, depending on how the page layout (fixed global header) is structured.
* @type {Boolean}
*/
canUsePopover = 'popover' in HTMLElement.prototype && CSS.supports('anchor-name', '--comment-reactions');
/** @type {Record<string, object[]> | null} */
reactionCache = null;
/** @type {Intl.ListFormat} */
Expand All @@ -531,13 +535,19 @@ Bugzilla.BugModal.CommentReactions = class CommentReactions {
this.$picker = $wrapper.querySelector('.picker');
/** @type {Number} */
this.commentId = Number(/** @type {HTMLElement} */ ($wrapper.parentElement.querySelector('.comment')).dataset.id);
/** @type {string} */
this.anchorName = `--comment-${this.commentId}-reactions`;

// Users cannot react on old bugs
if (!this.$anchor) {
return;
}

if (this.canUsePopover) {
// Set the anchor name dynamically
this.$wrapper.style.setProperty('anchor-name', this.anchorName);
this.$picker.style.setProperty('position-anchor', this.anchorName);

this.$anchor.popoverTargetElement = this.$picker;
this.$anchor.popoverTargetAction = 'toggle';
this.$picker.popover = 'auto';
Expand Down
Loading