Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit c1c545c

Browse files
authored
fix(core): set fractional breakpoints to .98 instead of .9 (#1308)
Setting the breakpoint value to .9 leads the browser to incorrectly round-up and cause overlap with fractional pixels and their upper bound. This leads to unintended consequences in downstream consumers like our MediaObserver and MatchMedia providers.
1 parent 4bb2c92 commit c1c545c

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/lib/core/breakpoints/data/break-points.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,52 @@ import {BreakPoint} from '../break-point';
1313
export const DEFAULT_BREAKPOINTS: BreakPoint[] = [
1414
{
1515
alias: 'xs',
16-
mediaQuery: 'screen and (min-width: 0px) and (max-width: 599.9px)',
16+
mediaQuery: 'screen and (min-width: 0px) and (max-width: 599.98px)',
1717
priority: 1000,
1818
},
1919
{
2020
alias: 'sm',
21-
mediaQuery: 'screen and (min-width: 600px) and (max-width: 959.9px)',
21+
mediaQuery: 'screen and (min-width: 600px) and (max-width: 959.98px)',
2222
priority: 900,
2323
},
2424
{
2525
alias: 'md',
26-
mediaQuery: 'screen and (min-width: 960px) and (max-width: 1279.9px)',
26+
mediaQuery: 'screen and (min-width: 960px) and (max-width: 1279.98px)',
2727
priority: 800,
2828
},
2929
{
3030
alias: 'lg',
31-
mediaQuery: 'screen and (min-width: 1280px) and (max-width: 1919.9px)',
31+
mediaQuery: 'screen and (min-width: 1280px) and (max-width: 1919.98px)',
3232
priority: 700,
3333
},
3434
{
3535
alias: 'xl',
36-
mediaQuery: 'screen and (min-width: 1920px) and (max-width: 4999.9px)',
36+
mediaQuery: 'screen and (min-width: 1920px) and (max-width: 4999.98px)',
3737
priority: 600,
3838
},
3939
{
4040
alias: 'lt-sm',
4141
overlapping: true,
42-
mediaQuery: 'screen and (max-width: 599.9px)',
42+
mediaQuery: 'screen and (max-width: 599.98px)',
4343
priority: 950,
4444
},
4545
{
4646
alias: 'lt-md',
4747
overlapping: true,
48-
mediaQuery: 'screen and (max-width: 959.9px)',
48+
mediaQuery: 'screen and (max-width: 959.98px)',
4949
priority: 850,
5050
},
5151
{
5252
alias: 'lt-lg',
5353
overlapping: true,
54-
mediaQuery: 'screen and (max-width: 1279.9px)',
54+
mediaQuery: 'screen and (max-width: 1279.98px)',
5555
priority: 750,
5656
},
5757
{
5858
alias: 'lt-xl',
5959
overlapping: true,
6060
priority: 650,
61-
mediaQuery: 'screen and (max-width: 1919.9px)',
61+
mediaQuery: 'screen and (max-width: 1919.98px)',
6262
},
6363
{
6464
alias: 'gt-xs',

src/lib/core/breakpoints/data/orientation-break-points.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import {BreakPoint} from '../break-point';
1010

1111
/* tslint:disable */
12-
const HANDSET_PORTRAIT = '(orientation: portrait) and (max-width: 599.9px)';
13-
const HANDSET_LANDSCAPE = '(orientation: landscape) and (max-width: 959.9px)';
12+
const HANDSET_PORTRAIT = '(orientation: portrait) and (max-width: 599.98px)';
13+
const HANDSET_LANDSCAPE = '(orientation: landscape) and (max-width: 959.98px)';
1414

15-
const TABLET_PORTRAIT = '(orientation: portrait) and (min-width: 600px) and (max-width: 839.9px)';
16-
const TABLET_LANDSCAPE = '(orientation: landscape) and (min-width: 960px) and (max-width: 1279.9px)';
15+
const TABLET_PORTRAIT = '(orientation: portrait) and (min-width: 600px) and (max-width: 839.98px)';
16+
const TABLET_LANDSCAPE = '(orientation: landscape) and (min-width: 960px) and (max-width: 1279.98px)';
1717

1818
const WEB_PORTRAIT = '(orientation: portrait) and (min-width: 840px)';
1919
const WEB_LANDSCAPE = '(orientation: landscape) and (min-width: 1280px)';

src/lib/core/match-media/mock/mock-match-media.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ describe('mock-match-media', () => {
259259
it('activates overlapping breakpoints correct', () => {
260260
mediaController.activate('xs', true);
261261
expect(mediaController
262-
.isActive('screen and (min-width: 0px) and (max-width: 599.9px)'))
262+
.isActive('screen and (min-width: 0px) and (max-width: 599.98px)'))
263263
.toBe(true);
264264
expect(mediaController
265-
.isActive('screen and (min-width: 600px) and (max-width: 959.9px)'))
265+
.isActive('screen and (min-width: 600px) and (max-width: 959.98px)'))
266266
.toBe(false);
267267
expect(mediaController
268-
.isActive('screen and (max-width: 599.9px)'))
268+
.isActive('screen and (max-width: 599.98px)'))
269269
.toBe(true);
270270
});
271271
});

src/lib/core/media-observer/media-observer.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('media-observer', () => {
178178
describe('with custom BreakPoints', () => {
179179
const gtXsMediaQuery = 'screen and (min-width:120px) and (orientation:landscape)';
180180
const superXLQuery = 'screen and (min-width:10000px)';
181-
const smMediaQuery = 'screen and (min-width: 600px) and (max-width: 959.9px)';
181+
const smMediaQuery = 'screen and (min-width: 600px) and (max-width: 959.98px)';
182182

183183
const CUSTOM_BREAKPOINTS = [
184184
{alias: 'slate.xl', priority: 11000, mediaQuery: superXLQuery},
@@ -233,7 +233,7 @@ describe('media-observer', () => {
233233
});
234234

235235
describe('with layout "print" configured', () => {
236-
const mdMediaQuery = 'screen and (min-width: 960px) and (max-width: 1279.9px)';
236+
const mdMediaQuery = 'screen and (min-width: 960px) and (max-width: 1279.98px)';
237237

238238
beforeEach(() => {
239239
// Configure testbed to prepare services
@@ -285,7 +285,7 @@ describe('media-observer', () => {
285285
});
286286

287287
describe('with layout print NOT configured', () => {
288-
const smMediaQuery = 'screen and (min-width: 600px) and (max-width: 959.9px)';
288+
const smMediaQuery = 'screen and (min-width: 600px) and (max-width: 959.98px)';
289289

290290
beforeEach(() => {
291291
// Configure testbed to prepare services

0 commit comments

Comments
 (0)