Skip to content

Fix strange UI behavior of cancelling dismiss review modal #25133

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

Merged
merged 2 commits into from
Jun 8, 2023
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
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
</div>
<div class="gt-df gt-ac gt-gap-3">
{{if (and $.Permission.IsAdmin (or (eq .Review.Type 1) (eq .Review.Type 3)) (not $.Issue.IsClosed))}}
<a href="#" class="ui muted icon gt-df gt-ac dismiss-review-btn" data-review-id="dismiss-review-{{.Review.ID}}" data-tooltip-content="{{$.locale.Tr "repo.issues.dismiss_review"}}">
<a href="#" class="ui muted icon gt-df gt-ac show-modal" data-review-id="dismiss-review-{{.Review.ID}}" data-tooltip-content="{{$.locale.Tr "repo.issues.dismiss_review"}}" data-modal="#dismiss-review-modal">
{{svg "octicon-x" 20}}
</a>
<div class="ui small modal" id="dismiss-review-modal">
<div class="ui small modal dismiss-review-modal" id="dismiss-review-modal">
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is wrong.

You are using the same id="dismiss-review-modal" in a range loop

Please revert or fix ASAP.

Copy link
Member

Choose a reason for hiding this comment

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

The id is not introduced by this PR so we can send a new PR to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

This ID was never used.

But this PR uses it by data-modal="#dismiss-review-modal".

Then which modal does it refer to?

Copy link
Member

Choose a reason for hiding this comment

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

The problem is inside range there will be multiple iterations but HTML ids must be unique in the whole page. I think the solution is to move the modal outside the range as there can effectively only be one visible at a time.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a quick fix, I think it can be combined with a ID, like #dismiss-review-modal-{{.Review.ID}}

Copy link
Member

@silverwind silverwind Jun 8, 2023

Choose a reason for hiding this comment

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

Yes, seems like a good temporary solution. The modal depends on .Review.ID so can not be easily be moved outside the loop as-is.

<div class="header">
{{$.locale.Tr "repo.issues.dismiss_review"}}
</div>
Expand Down
7 changes: 0 additions & 7 deletions web_src/js/features/repo-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,6 @@ export function initRepoIssueComments() {
).then(() => window.location.reload());
});

$('.dismiss-review-btn').on('click', function (e) {
e.preventDefault();
const $this = $(this);
const $dismissReviewModal = $this.next();
$dismissReviewModal.modal('show');
});

$(document).on('click', (event) => {
const urlTarget = $(':target');
if (urlTarget.length === 0) return;
Expand Down