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

Navbar scroll: unintended scroll while tabing inside navbar #1274

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ffe0d88
First attempt
louismaximepiton Jul 4, 2022
71c8d85
Merge branch 'main' into main-lmp-navbar-scroll-fix
louismaximepiton Nov 9, 2022
97ae625
Handle the differents sizes of header
louismaximepiton Nov 9, 2022
81ad1a8
Merge branch 'main' into main-lmp-navbar-scroll-fix
julien-deramond Dec 26, 2022
2629dc9
Merge branch 'main' into main-lmp-navbar-scroll-fix
louismaximepiton Jan 18, 2023
26b3210
Actualizing the CSS and js to be smaller and leave less
louismaximepiton Jan 18, 2023
d0d5675
fix tests
louismaximepiton Jan 18, 2023
55dca2c
Merge branch 'main' into main-lmp-navbar-scroll-fix
louismaximepiton Feb 14, 2023
c50284a
Split this PR in two.
louismaximepiton Feb 14, 2023
fb4c0e3
Re introduce things that shouldn't be removed.
louismaximepiton Feb 14, 2023
f01be59
Merge branch 'main' into main-lmp-navbar-scroll-fix
louismaximepiton Mar 21, 2023
fb4c064
Enhance the a11y message
louismaximepiton Mar 21, 2023
74ba5ff
Merge branch 'main' into main-lmp-navbar-scroll-fix
louismaximepiton Apr 25, 2023
4d6b77f
fix(review)
louismaximepiton May 30, 2023
334828d
Merge branch 'main' into main-lmp-navbar-scroll-fix
julien-deramond Jul 27, 2023
fc61c2f
Fix lint
julien-deramond Jul 27, 2023
cbe8292
Values adjustements
julien-deramond Jul 27, 2023
1d48c99
Update migration guide and envariable some values to avoid changing them
louismaximepiton Jul 27, 2023
7c1607c
Change default value of $enable-fixed-header in the docs
julien-deramond Jul 28, 2023
770be41
Merge remote-tracking branch 'origin/main' into main-lmp-navbar-scrol…
louismaximepiton Nov 30, 2023
a6bdb91
Introduce `scroll-margin` instead of `scroll-padding`
louismaximepiton Nov 30, 2023
3fe8b9b
.
louismaximepiton Nov 30, 2023
bbe0bd3
Merge branch 'main' into main-lmp-navbar-scroll-fix
louismaximepiton Jan 4, 2024
de2f723
.
louismaximepiton Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"path": "./dist/css/boosted-reboot.css",
"maxSize": "4.5 kB"
"maxSize": "4.75 kB"
},
{
"path": "./dist/css/boosted-reboot.min.css",
Expand All @@ -26,7 +26,7 @@
},
{
"path": "./dist/css/boosted.css",
"maxSize": "44.5 kB"
"maxSize": "44.75 kB"
},
{
"path": "./dist/css/boosted.min.css",
Expand Down
37 changes: 27 additions & 10 deletions scss/_reboot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,37 @@
scroll-behavior: smooth;
}
}
}

// Boosted mod: Improve focus visibility when fixed/sticky header is used
// See https://caniuse.com/?search=scroll-padding
// scss-docs-start scroll-offset
@if $enable-fixed-header {
scroll-padding-top: $scroll-offset-top * .5;

@include media-breakpoint-up(lg) {
scroll-padding-top: $scroll-offset-top;
// Boosted mod: Improve focus visibility when fixed/sticky header is used
// See https://caniuse.com/?search=scroll-padding
// scss-docs-start scroll-offset
@if $enable-fixed-header {
main {
a,
button,
input,
select,
textarea,
h2,
h3,
h4,
[tabindex="0"] {
scroll-margin-top: calc(#{$scroll-offset-top} * .5 + 1rem); // stylelint-disable-line function-disallowed-list
scroll-margin-bottom: 100px;

@include media-breakpoint-up(md) {
scroll-margin-top: calc(#{$scroll-offset-top} + 2rem); // stylelint-disable-line function-disallowed-list

.header-minimized ~ & {
scroll-margin-top: $scroll-offset-top;
}
}
}
}
// scss-docs-end scroll-offset
// End mod
}
// scss-docs-end scroll-offset
// End mod


// Body
Expand Down
4 changes: 2 additions & 2 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ $enable-validation-icons: true !default;
$enable-negative-margins: false !default;
$enable-deprecation-messages: false !default;
$enable-important-utilities: true !default;
$enable-fixed-header: true !default; // Boosted mod: used to apply scroll-padding-top
$enable-fixed-header: true !default; // Boosted mod: used to apply scroll-margin-top

$enable-dark-mode: true !default;
$color-mode-type: data !default; // `data` or `media-query`
Expand Down Expand Up @@ -2274,7 +2274,7 @@ $pre-line-height: 1.25 !default;
//

//// Scroll margin
$scroll-offset-top: $spacer * 6 !default; // Matching .navbar computed height
$scroll-offset-top: $spacer * 5 !default; // Matching .navbar computed height

//// Back to top
// scss-docs-start back-to-top
Expand Down
8 changes: 0 additions & 8 deletions site/assets/scss/_boosted.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
// stylelint-disable selector-max-id
:root {
scroll-padding-top: $offset-top / 2;

@include media-breakpoint-up(lg) {
scroll-padding-top: $offset-top;
}
}

html,
body {
min-height: 100vh;
Expand Down
10 changes: 7 additions & 3 deletions site/assets/scss/_scrolling.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ main {
h3,
h4,
[tabindex="0"] {
scroll-margin-top: 80px;
scroll-margin-top: add($offset-top, .5rem);
scroll-margin-bottom: 100px;

@include media-breakpoint-up(md) {
scroll-margin-top: add($offset-top, 4rem);

.header-minimized ~ .bd-gutter & {
scroll-margin-top: 8.5rem;
scroll-margin-top: add($offset-top, 1.5rem);
}
}

@include media-breakpoint-up(lg) {
scroll-margin-top: add($offset-top, 2.5rem);

.header-minimized ~ .bd-gutter & {
scroll-margin-top: 5.5rem;
scroll-margin-top: $offset-top;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/5.3/getting-started/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Each component then specifies its own visible focus style when needed, for examp

#### Under a fixed header

When using a fixed (or sticky) header, tabbing backward often hides focused element under the header. Boosted sets `scroll-padding-top` property for such case. This feature is configurable in two ways:
When using a fixed (or sticky) header, tabbing backward often hides focused element under the header. Boosted sets `scroll-margin-top` and `scroll-margin-bottom` properties for such case. This feature is configurable in two ways:

1. `$scroll-offset-top` variable defines the offset,
2. and [`$enable-fixed-header` allows to drop this rule]({{< docsref "/customize/options" >}}) if you don't use a fixed header.
Expand Down