Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bootstrap
bootstrap
Commits
dfa017ad
Commit
dfa017ad
authored
5 years ago
by
ysds
Committed by
XhmikosR
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Always modal scroll top to 0
parent
05fb3905
1 merge request
!31948
Examples/Floating-labels: fix bad behavior with autofill
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/src/modal.js
+2
-4
js/src/modal.js
js/tests/unit/modal.spec.js
+8
-8
js/tests/unit/modal.spec.js
with
10 additions
and
12 deletions
+10
-12
js/src/modal.js
+
2
-
4
View file @
dfa017ad
...
@@ -60,7 +60,6 @@ const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY}`
...
@@ -60,7 +60,6 @@ const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY}`
const
EVENT_MOUSEDOWN_DISMISS
=
`mousedown.dismiss
${
EVENT_KEY
}
`
const
EVENT_MOUSEDOWN_DISMISS
=
`mousedown.dismiss
${
EVENT_KEY
}
`
const
EVENT_CLICK_DATA_API
=
`click
${
EVENT_KEY
}${
DATA_API_KEY
}
`
const
EVENT_CLICK_DATA_API
=
`click
${
EVENT_KEY
}${
DATA_API_KEY
}
`
const
CLASS_NAME_SCROLLABLE
=
'
modal-dialog-scrollable
'
const
CLASS_NAME_SCROLLBAR_MEASURER
=
'
modal-scrollbar-measure
'
const
CLASS_NAME_SCROLLBAR_MEASURER
=
'
modal-scrollbar-measure
'
const
CLASS_NAME_BACKDROP
=
'
modal-backdrop
'
const
CLASS_NAME_BACKDROP
=
'
modal-backdrop
'
const
CLASS_NAME_OPEN
=
'
modal-open
'
const
CLASS_NAME_OPEN
=
'
modal-open
'
...
@@ -249,11 +248,10 @@ class Modal {
...
@@ -249,11 +248,10 @@ class Modal {
this
.
_element
.
style
.
display
=
'
block
'
this
.
_element
.
style
.
display
=
'
block
'
this
.
_element
.
removeAttribute
(
'
aria-hidden
'
)
this
.
_element
.
removeAttribute
(
'
aria-hidden
'
)
this
.
_element
.
setAttribute
(
'
aria-modal
'
,
true
)
this
.
_element
.
setAttribute
(
'
aria-modal
'
,
true
)
this
.
_element
.
scrollTop
=
0
if
(
this
.
_dialog
.
classList
.
contains
(
CLASS_NAME_SCROLLABLE
)
&&
modalBody
)
{
if
(
modalBody
)
{
modalBody
.
scrollTop
=
0
modalBody
.
scrollTop
=
0
}
else
{
this
.
_element
.
scrollTop
=
0
}
}
if
(
transition
)
{
if
(
transition
)
{
...
...
This diff is collapsed.
Click to expand it.
js/tests/unit/modal.spec.js
+
8
-
8
View file @
dfa017ad
...
@@ -382,40 +382,40 @@ describe('Modal', () => {
...
@@ -382,40 +382,40 @@ describe('Modal', () => {
modal
.
show
()
modal
.
show
()
})
})
it
(
'
should set modal
body
scroll top to 0
if .modal-dialog-scrollable
'
,
done
=>
{
it
(
'
should set
.
modal
\'
s
scroll top to 0
'
,
done
=>
{
fixtureEl
.
innerHTML
=
[
fixtureEl
.
innerHTML
=
[
'
<div class="modal fade">
'
,
'
<div class="modal fade">
'
,
'
<div class="modal-dialog modal-dialog-scrollable">
'
,
'
<div class="modal-dialog">
'
,
'
<div class="modal-body"></div>
'
,
'
</div>
'
,
'
</div>
'
,
'
</div>
'
'
</div>
'
].
join
(
''
)
].
join
(
''
)
const
modalEl
=
fixtureEl
.
querySelector
(
'
.modal
'
)
const
modalEl
=
fixtureEl
.
querySelector
(
'
.modal
'
)
const
modalBody
=
modalEl
.
querySelector
(
'
.modal-body
'
)
const
modal
=
new
Modal
(
modalEl
)
const
modal
=
new
Modal
(
modalEl
)
modalEl
.
addEventListener
(
'
shown.bs.modal
'
,
()
=>
{
modalEl
.
addEventListener
(
'
shown.bs.modal
'
,
()
=>
{
expect
(
modal
Body
.
scrollTop
).
toEqual
(
0
)
expect
(
modal
El
.
scrollTop
).
toEqual
(
0
)
done
()
done
()
})
})
modal
.
show
()
modal
.
show
()
})
})
it
(
'
should set
.
modal
\'
s
scroll top to 0 if
.modal-dialog-scrollable and
modal body do not exists
'
,
done
=>
{
it
(
'
should set modal
body
scroll top to 0 if modal body do not exists
'
,
done
=>
{
fixtureEl
.
innerHTML
=
[
fixtureEl
.
innerHTML
=
[
'
<div class="modal fade">
'
,
'
<div class="modal fade">
'
,
'
<div class="modal-dialog modal-dialog-scrollable">
'
,
'
<div class="modal-dialog">
'
,
'
<div class="modal-body"></div>
'
,
'
</div>
'
,
'
</div>
'
,
'
</div>
'
'
</div>
'
].
join
(
''
)
].
join
(
''
)
const
modalEl
=
fixtureEl
.
querySelector
(
'
.modal
'
)
const
modalEl
=
fixtureEl
.
querySelector
(
'
.modal
'
)
const
modalBody
=
modalEl
.
querySelector
(
'
.modal-body
'
)
const
modal
=
new
Modal
(
modalEl
)
const
modal
=
new
Modal
(
modalEl
)
modalEl
.
addEventListener
(
'
shown.bs.modal
'
,
()
=>
{
modalEl
.
addEventListener
(
'
shown.bs.modal
'
,
()
=>
{
expect
(
modal
El
.
scrollTop
).
toEqual
(
0
)
expect
(
modal
Body
.
scrollTop
).
toEqual
(
0
)
done
()
done
()
})
})
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets