Skip to content

Commit fbe4423

Browse files
mwczkylebuch8
andauthored
fix: improve CLS rating in lighthouse (#1020)
* fix: improve CLS rating in lighthouse * visibility needs to be added to the final reveal keyframe * adding changelog Co-authored-by: Kyle Buchanan <[email protected]>
1 parent 17c36a6 commit fbe4423

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG-prerelease.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Prerelease 55 ( TBD )
22

33
- [](https://github.com/patternfly/patternfly-elements/commit/)
4+
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: improve CLS rating in lighthouse (#1020)
45

56
## Prerelease 54 ( 2020-07-31 )
67

elements/pfelement/src/pfelement.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@ body {
1212

1313
body[unresolved] {
1414
opacity: 0;
15+
visibility: hidden;
1516
animation: reveal var(--pfe-reveal-duration) var(--pfe-reveal-delay) 1
1617
forwards;
1718
}
1819

1920
@keyframes reveal {
20-
from {
21+
0% {
22+
visibility: hidden;
2123
opacity: 0;
2224
}
23-
to {
25+
1% {
26+
visibility: visible;
27+
}
28+
100% {
2429
opacity: 1;
30+
visibility: visible;
2531
}
2632
}

elements/pfelement/test/fouc-test.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ <h2 slot="pfe-card--header">Card 1</h2>This is pfe-card.
4343
test('body[unresolved] should cause the page to be hidden', () => {
4444
document.body.setAttribute('unresolved', '');
4545
const styles = document.body.computedStyleMap();
46-
assert.equal(styles.get('opacity').value, 0, 'body[unresolved] causes the page to be hidden');
46+
assert.equal(styles.get('opacity').value, 0, 'body[unresolved] causes the page to have 0 opacity');
47+
assert.equal(styles.get('visibility').value, "hidden", 'body[unresolved] causes the page to be hidden');
4748
});
4849

4950
test('removing body[unresolved] should cause the page to be revealed', done => {
@@ -61,14 +62,16 @@ <h2 slot="pfe-card--header">Card 1</h2>This is pfe-card.
6162
if (styles.get('opacity').value === 1) {
6263
clearTimeout(tid);
6364
clearInterval(iid);
64-
assert.equal(styles.get('opacity').value, 1, 'removing body[unresolved] causes the page to be revealed');
65+
assert.equal(styles.get('opacity').value, 1, 'removing body[unresolved] causes the page to have 1 opacity');
66+
assert.equal(styles.get('visibility').value, "visible", 'body[unresolved] causes the page to be visible');
6567
done();
6668
}
6769
}, 50);
6870

6971
tid = setTimeout(() => {
7072
clearInterval(id);
7173
assert.equal(styles.get('opacity').value, 1, 'removing body[unresolved] causes the page to be revealed');
74+
assert.equal(styles.get('visibility').value, "visible", 'body[unresolved] causes the page to be visible');
7275
done();
7376
}, 1500);
7477
});

0 commit comments

Comments
 (0)