Skip to content

Commit 94512ee

Browse files
authored
Fix Citation modal responsiveness and clipboard copy (#29799)
The modal was broken in two ways: - On small screens, the input box was partially hanging outside the modal. Fixed with flexbox and increased modal width. - The clipboard copy was not working because the modal had both `data-clipboard-text` and `data-clipboard-target`, while we only support one of those. Made a small tweak in clipboard as well so that it will still fall back to target if text is empty.
1 parent 256a1ee commit 94512ee

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

templates/repo/cite/cite_buttons.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ BibTeX
66
</button>
77
<!-- the value will be updated by initCitationFileCopyContent, the code below is used to avoid UI flicking -->
88
<input id="citation-copy-content" value="" size="1" readonly>
9-
<button class="ui icon button" id="citation-clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy"}}" data-clipboard-text="" data-clipboard-target="#citation-copy-content">
9+
<button class="ui icon button" id="citation-clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy"}}" data-clipboard-target="#citation-copy-content">
1010
{{svg "octicon-copy"}}
1111
</button>

templates/repo/cite/cite_modal.tmpl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
<div class="ui tiny modal" id="cite-repo-modal">
1+
<div class="ui small modal" id="cite-repo-modal">
22
<div class="header">
33
{{ctx.Locale.Tr "repo.cite_this_repo"}}
44
</div>
55
<div class="content">
66
<div class="ui stackable secondary menu">
7-
<div class="fitted item">
8-
<div class="ui action input" id="citation-panel">
9-
{{template "repo/cite/cite_buttons" .}}
10-
<a id="goto-citation-btn" class="ui basic jump icon button" href="{{$.RepoLink}}/src/{{$.BranchName}}/CITATION.cff" data-tooltip-content="{{ctx.Locale.Tr "repo.find_file.go_to_file"}}">
11-
{{svg "octicon-file-moved"}}
12-
</a>
13-
</div>
7+
<div class="ui action input" id="citation-panel">
8+
{{template "repo/cite/cite_buttons" .}}
9+
<a id="goto-citation-btn" class="ui basic jump icon button" href="{{$.RepoLink}}/src/{{$.BranchName}}/CITATION.cff" data-tooltip-content="{{ctx.Locale.Tr "repo.find_file.go_to_file"}}">
10+
{{svg "octicon-file-moved"}}
11+
</a>
1412
</div>
1513
</div>
1614
</div>

web_src/css/repo.css

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,13 +2035,8 @@
20352035
}
20362036

20372037
#cite-repo-modal #citation-panel {
2038-
width: 500px;
2039-
}
2040-
2041-
@media (max-width: 767.98px) {
2042-
#cite-repo-modal #citation-panel {
2043-
width: 100%;
2044-
}
2038+
display: flex;
2039+
width: 100%;
20452040
}
20462041

20472042
#cite-repo-modal #citation-panel input {
@@ -2061,6 +2056,7 @@
20612056
padding: 5px 10px;
20622057
font-size: 1.2em;
20632058
line-height: 1.4;
2059+
flex: 1;
20642060
}
20652061

20662062
#cite-repo-modal #citation-panel #citation-copy-apa,

web_src/js/features/clipboard.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ export function initGlobalCopyToClipboardListener() {
1515

1616
e.preventDefault();
1717

18-
let text;
19-
if (target.hasAttribute('data-clipboard-text')) {
20-
text = target.getAttribute('data-clipboard-text');
21-
} else {
18+
let text = target.getAttribute('data-clipboard-text');
19+
if (!text) {
2220
text = document.querySelector(target.getAttribute('data-clipboard-target'))?.value;
2321
}
2422

0 commit comments

Comments
 (0)