From 7bc6eab1870a31cb49632ddb9d66599842b36f9b Mon Sep 17 00:00:00 2001 From: gitstart Date: Tue, 13 Dec 2022 08:40:22 +0000 Subject: [PATCH 1/2] fix: adds focus outline on single item title --- .../components/RelationInput/RelationInput.js | 18 ++-- .../__snapshots__/RelationInput.test.js.snap | 90 ++++++++++--------- 2 files changed, 59 insertions(+), 49 deletions(-) diff --git a/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js b/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js index 7b1b5a7a6d..21de836d85 100644 --- a/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js +++ b/packages/core/admin/admin/src/content-manager/components/RelationInput/RelationInput.js @@ -24,10 +24,14 @@ import { RELATION_ITEM_HEIGHT } from './constants'; import { usePrev } from '../../hooks'; const LinkEllipsis = styled(Link)` - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - display: inherit; + display: block; + + > span { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + display: block; + } `; const BoxEllipsis = styled(Box)` @@ -304,6 +308,8 @@ const RelationInput = ({ {({ data, index, style }) => { const { publicationState, href, mainField, id } = data[index]; const statusColor = publicationState === 'draft' ? 'secondary' : 'success'; + // Use Box to fix the issue of BoxEllipsis causing LinkEllipsis :focus-visible:after "outline" hidden + const BoxWrapper = href ? Box : BoxEllipsis; return ( - + {href ? ( @@ -334,7 +340,7 @@ const RelationInput = ({ )} - + {publicationState && ( diff --git a/packages/core/admin/admin/src/content-manager/components/RelationInput/tests/__snapshots__/RelationInput.test.js.snap b/packages/core/admin/admin/src/content-manager/components/RelationInput/tests/__snapshots__/RelationInput.test.js.snap index 085a24a6bf..abce901c7d 100644 --- a/packages/core/admin/admin/src/content-manager/components/RelationInput/tests/__snapshots__/RelationInput.test.js.snap +++ b/packages/core/admin/admin/src/content-manager/components/RelationInput/tests/__snapshots__/RelationInput.test.js.snap @@ -49,7 +49,7 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = min-width: 0px; } -.c23 { +.c22 { background: #eaf5ff; padding-top: 4px; padding-right: 8px; @@ -60,11 +60,11 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = border: 1px solid #b8e1ff; } -.c26 { +.c25 { padding-left: 16px; } -.c28 { +.c27 { color: #666687; width: 12px; } @@ -165,13 +165,13 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = color: #4945ff; } -.c22 { +.c21 { font-size: 0.875rem; line-height: 1.43; color: #32324d; } -.c25 { +.c24 { font-size: 0.875rem; line-height: 1.43; font-weight: 600; @@ -210,7 +210,7 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = margin-top: 4px; } -.c29 path { +.c28 path { fill: #666687; } @@ -300,7 +300,7 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = width: 0.5625rem; } -.c24 .c5 { +.c23 .c5 { color: #0c75af; } @@ -308,7 +308,7 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = color: #328048; } -.c20 { +.c19 { display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -324,31 +324,31 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = outline: none; } -.c20 svg path { +.c19 svg path { -webkit-transition: fill 150ms ease-out; transition: fill 150ms ease-out; fill: currentColor; } -.c20 svg { +.c19 svg { font-size: 0.625rem; } -.c20 .c5 { +.c19 .c5 { -webkit-transition: color 150ms ease-out; transition: color 150ms ease-out; color: currentColor; } -.c20:hover { +.c19:hover { color: #7b79ff; } -.c20:active { +.c19:active { color: #271fe0; } -.c20:after { +.c19:after { -webkit-transition-property: all; transition-property: all; -webkit-transition-duration: 0.2s; @@ -363,11 +363,11 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = border: 2px solid transparent; } -.c20:focus-visible { +.c19:focus-visible { outline: none; } -.c20:focus-visible:after { +.c19:focus-visible:after { border-radius: 8px; content: ''; position: absolute; @@ -407,26 +407,30 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = bottom: 0; } -.c21 { +.c20 { + display: block; +} + +.c20 > span { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + display: block; +} + +.c29 > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inherit; } -.c19 > span { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - display: inherit; -} - -.c27 svg path { +.c26 svg path { fill: #8e8ea9; } -.c27:hover svg path, -.c27:focus svg path { +.c26:hover svg path, +.c26:focus svg path { fill: #666687; } @@ -585,18 +589,18 @@ exports[`Content-Manager || RelationInput should render and match snapshot 1`] = class="c16 c17" >
Draft