-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiDataGrid] Fixed focus ring to be contained in cell #5194
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,11 +51,24 @@ $euiDataGridStyles: ( | |
} | ||
|
||
@mixin euiDataGridCellFocus { | ||
border: 1px solid transparent; | ||
box-shadow: 0 0 0 2px $euiFocusRingColor; | ||
border-radius: 1px; | ||
z-index: 2; // Needed so it sits above potential striping in the next row | ||
outline: none; // Remove outline as we're handling it manually | ||
|
||
// We don't want to use a border on the focused cell directly because we want to maintain the light gray borders | ||
// We can't use a box shadow or outline because it would be contained outside the cell and it would be cut by other surrounding cells | ||
// So the solution is to use use a pseudo-element. It allows us to use a border, and it can be contained inside the cell by positioning it with an absolute position. | ||
&::after { | ||
content: ''; | ||
Comment on lines
+59
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At first I was worried about adding a pseudo element because I was told that extra elements can impact the performance, but because this is only add on focus it doesn't seem to have an impact. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ that I'm not overly concerned about the performance and I think this is just fine, but wanted to add that we can use an inset box-shadow to get a border inside (vs. outside) the cell if it ever becomes a perf issue: CodeSandbox demo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @constancecchen! 🎉 At some point, I added the inset There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh right, makes sense if we want that border-radius! |
||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
border: $euiBorderWidthThick solid $euiFocusRingColor; | ||
border-radius: $euiBorderRadiusSmall; | ||
z-index: 2; // We want this to be on top of all the content | ||
pointer-events: none; // Because we put it with a higher z-index we don't want to make it clickable this way we allow selecting the content behind | ||
} | ||
} | ||
|
||
@mixin euiDataGridRowCell { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested and I don't see a problem of having this
overflow: hidden;
for.euiDataGridRowCell
. Am I missing something? Does it impact any use case?In practice having it or not having it is almost the same. But the focus ring now that is contained looks a little bit better with the
overflow: hidden
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I could tell, the cell contents itself already has
overflow: hidden
so I doubt this should have an impact. It certainly should not with the normal/default settings.