Skip to content

Commit 95ab0d0

Browse files
authored
Prevent .show-on-focus to change width/height (#2391)
* Update `.show-on-focus` to not reset width/height * Add `ShowOnFocus` story * Create .changeset/shy-pumpkins-walk.md
1 parent 5dc4fea commit 95ab0d0

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

.changeset/shy-pumpkins-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/css": patch
3+
---
4+
5+
Prevent `.show-on-focus` to change width/height

docs/src/stories/utilities/Layout.stories.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ export const ScreenReaderOnly = ({}) => (
285285
</div>
286286
)
287287

288+
export const ShowOnFocus = ({}) => (
289+
<div>
290+
<div class="mb-2">Click here and press tab to make the ".show-on-focus" element appear</div>
291+
<button type="button" class="btn show-on-focus">.show-on-focus</button>
292+
</div>
293+
)
294+
288295
export const MediaObject = ({}) => (
289296
<div class="clearfix p-3 border">
290297
<div class="float-left p-3 mr-3 color-bg-subtle">

src/utilities/visibility-display.scss

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,18 @@
107107

108108
// Only display content on focus
109109
.show-on-focus {
110-
position: absolute;
111-
width: 1px;
112-
height: 1px;
113-
margin: 0;
114-
overflow: hidden;
115-
clip: rect(1px, 1px, 1px, 1px);
110+
position: absolute !important;
111+
112+
&:not(:focus) {
113+
width: 1px !important;
114+
height: 1px !important;
115+
padding: 0 !important;
116+
overflow: hidden !important;
117+
clip: rect(1px, 1px, 1px, 1px) !important;
118+
border: 0 !important;
119+
}
116120

117121
&:focus {
118122
z-index: 999;
119-
width: auto;
120-
height: auto;
121-
clip: auto;
122123
}
123124
}

0 commit comments

Comments
 (0)