Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8d8e8426
Commit
8d8e8426
authored
Nov 19, 2020
by
Thomas Randolph
Committed by
Nicolò Maria Mezzopera
Nov 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scroll exactly to the top of a discussion on the MR Overview tab
parent
edeef4e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
22 deletions
+43
-22
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+29
-16
app/assets/javascripts/notes/mixins/discussion_navigation.js
app/assets/javascripts/notes/mixins/discussion_navigation.js
+5
-4
changelogs/unreleased/defect-jump-to-next-overscroll.yml
changelogs/unreleased/defect-jump-to-next-overscroll.yml
+5
-0
spec/frontend/lib/utils/common_utils_spec.js
spec/frontend/lib/utils/common_utils_spec.js
+1
-0
spec/frontend/notes/mixins/discussion_navigation_spec.js
spec/frontend/notes/mixins/discussion_navigation_spec.js
+3
-2
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
8d8e8426
...
...
@@ -218,23 +218,36 @@ export const isMetaKey = e => e.metaKey || e.ctrlKey || e.altKey || e.shiftKey;
export
const
isMetaClick
=
e
=>
e
.
metaKey
||
e
.
ctrlKey
||
e
.
which
===
2
;
export
const
contentTop
=
()
=>
{
const
perfBar
=
$
(
'
#js-peek
'
).
outerHeight
()
||
0
;
const
mrTabsHeight
=
$
(
'
.merge-request-tabs
'
).
outerHeight
()
||
0
;
const
headerHeight
=
$
(
'
.navbar-gitlab
'
).
outerHeight
()
||
0
;
const
diffFilesChanged
=
$
(
'
.js-diff-files-changed
'
).
outerHeight
()
||
0
;
const
isDesktop
=
breakpointInstance
.
isDesktop
();
const
diffFileTitleBar
=
(
isDesktop
&&
$
(
'
.diff-file .file-title-flex-parent:visible
'
).
outerHeight
())
||
0
;
const
compareVersionsHeaderHeight
=
(
isDesktop
&&
$
(
'
.mr-version-controls
'
).
outerHeight
())
||
0
;
const
heightCalculators
=
[
()
=>
$
(
'
#js-peek
'
).
outerHeight
(),
()
=>
$
(
'
.navbar-gitlab
'
).
outerHeight
(),
()
=>
$
(
'
.merge-request-tabs
'
).
outerHeight
(),
()
=>
$
(
'
.js-diff-files-changed
'
).
outerHeight
(),
()
=>
{
const
isDesktop
=
breakpointInstance
.
isDesktop
();
const
diffsTabIsActive
=
window
.
mrTabs
?.
currentAction
===
'
diffs
'
;
let
size
;
if
(
isDesktop
&&
diffsTabIsActive
)
{
size
=
$
(
'
.diff-file .file-title-flex-parent:visible
'
).
outerHeight
();
}
return
(
perfBar
+
mrTabsHeight
+
headerHeight
+
diffFilesChanged
+
diffFileTitleBar
+
compareVersionsHeaderHeight
);
return
size
;
},
()
=>
{
let
size
;
if
(
breakpointInstance
.
isDesktop
())
{
size
=
$
(
'
.mr-version-controls
'
).
outerHeight
();
}
return
size
;
},
];
return
heightCalculators
.
reduce
((
totalHeight
,
calculator
)
=>
{
return
totalHeight
+
(
calculator
()
||
0
);
},
0
);
};
export
const
scrollToElement
=
(
element
,
options
=
{})
=>
{
...
...
app/assets/javascripts/notes/mixins/discussion_navigation.js
View file @
8d8e8426
import
{
mapGetters
,
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
scrollToElementWithContext
}
from
'
~/lib/utils/common_utils
'
;
import
{
scrollToElementWithContext
,
scrollToElement
}
from
'
~/lib/utils/common_utils
'
;
import
eventHub
from
'
../event_hub
'
;
/**
* @param {string} selector
* @returns {boolean}
*/
function
scrollTo
(
selector
)
{
function
scrollTo
(
selector
,
{
withoutContext
=
false
}
=
{}
)
{
const
el
=
document
.
querySelector
(
selector
);
const
scrollFunction
=
withoutContext
?
scrollToElement
:
scrollToElementWithContext
;
if
(
el
)
{
scroll
ToElementWithContext
(
el
);
scroll
Function
(
el
);
return
true
;
}
...
...
@@ -35,7 +36,7 @@ function diffsJump({ expandDiscussion }, id) {
function
discussionJump
({
expandDiscussion
},
id
)
{
const
selector
=
`div.discussion[data-discussion-id="
${
id
}
"]`
;
expandDiscussion
({
discussionId
:
id
});
return
scrollTo
(
selector
);
return
scrollTo
(
selector
,
{
withoutContext
:
true
}
);
}
/**
...
...
changelogs/unreleased/defect-jump-to-next-overscroll.yml
0 → 100644
View file @
8d8e8426
---
title
:
Scroll exactly to the top of a discussion on the MR Overview tab
merge_request
:
47970
author
:
type
:
fixed
spec/frontend/lib/utils/common_utils_spec.js
View file @
8d8e8426
...
...
@@ -220,6 +220,7 @@ describe('common_utils', () => {
beforeEach
(()
=>
{
elem
=
document
.
createElement
(
'
div
'
);
window
.
innerHeight
=
windowHeight
;
window
.
mrTabs
=
{
currentAction
:
'
show
'
};
jest
.
spyOn
(
$
.
fn
,
'
animate
'
);
jest
.
spyOn
(
$
.
fn
,
'
offset
'
).
mockReturnValue
({
top
:
elemTop
});
});
...
...
spec/frontend/notes/mixins/discussion_navigation_spec.js
View file @
8d8e8426
...
...
@@ -42,6 +42,7 @@ describe('Discussion navigation mixin', () => {
);
jest
.
spyOn
(
utils
,
'
scrollToElementWithContext
'
);
jest
.
spyOn
(
utils
,
'
scrollToElement
'
);
expandDiscussion
=
jest
.
fn
();
const
{
actions
,
...
notesRest
}
=
notesModule
();
...
...
@@ -133,7 +134,7 @@ describe('Discussion navigation mixin', () => {
});
it
(
'
scrolls to element
'
,
()
=>
{
expect
(
utils
.
scrollToElement
WithContext
).
toHaveBeenCalledWith
(
expect
(
utils
.
scrollToElement
).
toHaveBeenCalledWith
(
findDiscussion
(
'
div.discussion
'
,
expected
),
);
});
...
...
@@ -200,7 +201,7 @@ describe('Discussion navigation mixin', () => {
});
it
(
'
scrolls to discussion
'
,
()
=>
{
expect
(
utils
.
scrollToElement
WithContext
).
toHaveBeenCalledWith
(
expect
(
utils
.
scrollToElement
).
toHaveBeenCalledWith
(
findDiscussion
(
'
div.discussion
'
,
expected
),
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment