Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/stories/utilities/Layout.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ export const ScreenReaderOnly = ({}) => (
</div>
)

export const ShowOnFocus = ({}) => (
<div>
<div class="mb-2">Click here and press tab to make the ".show-on-focus" element appear</div>
<button type="button" class="btn show-on-focus">.show-on-focus</button>
</div>
)

export const MediaObject = ({}) => (
<div class="clearfix p-3 border">
<div class="float-left p-3 mr-3 color-bg-subtle">
Expand Down
19 changes: 10 additions & 9 deletions src/utilities/visibility-display.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@

// Only display content on focus
.show-on-focus {
position: absolute;
width: 1px;
height: 1px;
margin: 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed margin so negative margin can be used for positioning.

overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
position: absolute !important;

&:not(:focus) {
width: 1px !important;
height: 1px !important;
padding: 0 !important;
overflow: hidden !important;
clip: rect(1px, 1px, 1px, 1px) !important;
border: 0 !important;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added padding + border since they can increase the size of an element.

}

&:focus {
z-index: 999;
width: auto;
height: auto;
clip: auto;
}
}