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

Fixed Issue of Review Menu Shown Behind #32631

Merged
merged 6 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions templates/repo/diff/box.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@
<input type="checkbox" name="{{$file.GetDiffFileName}}" autocomplete="off"{{if $file.IsViewed}} checked{{end}}> {{ctx.Locale.Tr "repo.pulls.has_viewed_file"}}
</label>
{{end}}
<div class="ui dropdown basic">
<div class="ui tiny js-btn-diff-file-menu">
{{svg "octicon-kebab-horizontal" 18 "icon tw-mx-2"}}
<div class="ui menu">
<div class="tippy-target">
{{if not (or $file.IsIncomplete $file.IsBin $file.IsSubmodule)}}
<button class="unescape-button item">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button>
<button class="escape-button tw-hidden item">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button>
<a class="unescape-button item">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</a>
<a class="escape-button tw-hidden item">{{ctx.Locale.Tr "repo.escape_control_characters"}}</a>
{{end}}
{{if and (not $file.IsSubmodule) (not $.PageIsWiki)}}
{{if $file.IsDeleted}}
Expand Down
21 changes: 21 additions & 0 deletions web_src/js/features/repo-diff.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import $ from 'jquery';
import {createTippy} from '../modules/tippy.ts';
import {initCompReactionSelector} from './comp/ReactionSelector.ts';
import {initRepoIssueContentHistory} from './repo-issue-content.ts';
import {initDiffFileTree, initDiffFileList} from './repo-diff-filetree.ts';
Expand Down Expand Up @@ -225,3 +226,23 @@ export function initRepoDiffView() {
initViewedCheckboxListenerFor();
initExpandAndCollapseFilesButton();
}

export function initRepoDiffFileMenu() {
let tippyIndex = 0;
$('.js-btn-diff-file-menu').each(function () {
tippyIndex++;
this.setAttribute('data-diff-file-menu-tippy-target-id', tippyIndex);
const $menu = $(this).find('.tippy-target');
if ($menu.length < 1) return;
$menu[0].setAttribute('data-diff-file-menu-tippy-id', tippyIndex);
createTippy(this, {
content: $menu[0],
role: 'menu',
theme: 'menu',
trigger: 'click',
placement: 'bottom',
interactive: true,
hideOnClick: true,
});
});
}
9 changes: 8 additions & 1 deletion web_src/js/features/repo-unicode-escape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ export function initUnicodeEscapeButton() {

e.preventDefault();

const fileContent = btn.closest('.file-content, .non-diff-file-content');
let fileContent = btn.closest('.file-content, .non-diff-file-content');
if (!fileContent) {
const tippyTarget = btn.closest('.tippy-target');
if (tippyTarget) {
fileContent = document.querySelectorAll(`[data-diff-file-menu-tippy-target-id="${tippyTarget.getAttribute('data-diff-file-menu-tippy-id')}"]`)[0].closest('.file-content, .non-diff-file-content');
}
}
const fileView = fileContent?.querySelectorAll('.file-code, .file-view');
if (!fileView) return;
if (btn.matches('.escape-button')) {
for (const el of fileView) el.classList.add('unicode-escaped');
hideElem(btn);
Expand Down
3 changes: 2 additions & 1 deletion web_src/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {initSshKeyFormParser} from './features/sshkey-helper.ts';
import {initUserSettings} from './features/user-settings.ts';
import {initRepoActivityTopAuthorsChart, initRepoArchiveLinks} from './features/repo-common.ts';
import {initRepoMigrationStatusChecker} from './features/repo-migrate.ts';
import {initRepoDiffView} from './features/repo-diff.ts';
import {initRepoDiffView, initRepoDiffFileMenu} from './features/repo-diff.ts';
import {initOrgTeamSearchRepoBox, initOrgTeamSettings} from './features/org-team.ts';
import {initUserAuthWebAuthn, initUserAuthWebAuthnRegister} from './features/user-auth-webauthn.ts';
import {initRepoRelease, initRepoReleaseNew} from './features/repo-release.ts';
Expand Down Expand Up @@ -212,6 +212,7 @@ onDomReady(() => {
initUserAuthWebAuthnRegister,
initUserSettings,
initRepoDiffView,
initRepoDiffFileMenu,
initPdfViewer,
initScopedAccessTokenCategories,
initColorPickers,
Expand Down
Loading