-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[SharedUX] Replace Sass with Emotion, Round 1 #199885
base: main
Are you sure you want to change the base?
[SharedUX] Replace Sass with Emotion, Round 1 #199885
Conversation
0c39420
to
d3fe030
Compare
.euiHeaderSectionItem .euiButtonEmpty__text { | ||
// stop global header buttons from jumping during loading state | ||
display: flex; |
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 did not port these styles over, because I do not see the global header buttons jumping around during loading state.
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 just added this in a recent PR. See if you notice it when throttling your browser... in particular, the spaces button (loading rectangle) would jump up and right in a flash.
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.
Checked locally, and it looks like the jump is there if this is excluded.
CleanShot.2024-11-13.at.10.03.40.mp4
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.
Thanks @ryankeairns! I restored these styles in 8e4cd1d. I will try to improve my test method
@@ -71,6 +72,7 @@ Array [ | |||
aria-hidden="true" | |||
aria-labelledby="elasticMark" | |||
class="chrHeaderLogo__mark" | |||
css="You have tried to stringify object returned from \`css\` function. It isn't supposed to be used directly (e.g. as value of the \`className\` prop), but rather handed to emotion so it can handle it (e.g. as value of \`css\` prop)." |
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.
As far as I can tell, it is normal to see this message in a snapshot file when the component uses a css
prop that gets an object returned from the css
function.
@@ -102,11 +119,12 @@ export function HeaderLogo({ href, navigateToApp, loadingCount$, ...observables | |||
<img | |||
src={customizedLogo} | |||
className="chrHeaderLogo__mark" |
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 know we left these className in here because it's targeted some test files, what do you think about swapping this for testIds especially that it wont be apparent to some other person much later?
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.
@eokoneyo thanks for taking a look at this. I would prefer to leave this as it is. It will help this PR, and others like it, to avoid ballooning the refactoring into something larger than it needs to be. Changing this code could impact other code owners as well, and then add the need for more teams to review.
Edit: let me think more about this. One of the class names is used as a selector for production code. That probably isn't the best practice and there should be a more acceptable way.
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.
bb45851 replaced a className with a testId, since it was only needed for a test
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.
Heyy @tsullivan , @eokoneyo ,
Just curious from investigations perspective, I agree that tests should target test-id
s but is there a downside of keeping classNames
here?
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.
@logeekal The downside of using classNames for non-style purposes is that classNames are not a public contract, so they shouldn't be used for other things.
As we're replacing CSS/SASS with Emotion, for thoroughness, the typical followup will be to remove the className from the DOM, for thoroughness. We could break integrations if we fail to realize that some place in the repo is using that className as a selector in production code.
Relevant: 24f6977
@@ -184,7 +184,7 @@ export const focusUtilityBarAction = (containerElement: HTMLElement | null) => { | |||
* Resets keyboard focus on the page | |||
*/ | |||
export const resetKeyboardFocus = () => { | |||
document.querySelector<HTMLAnchorElement>('header.headerGlobalNav a.chrHeaderLogo')?.focus(); |
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.
@elastic/security-threat-hunting-investigations in reviewing this, let's consider accessibility. The way this works should keep a logical and intuitive flow in keyboard navigation.
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.
@michaelolo24 / @kqualters-elastic Any historical context here? Was this just added to remove keyboard focus?
As suggested by @tsullivan in the slack thread , I think I agree that we can use document.body.focus()
as well. Do you have any opinion?
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 am not sure on the context of this to be honest, seems it's used in conjunction with https://github.com/elastic/kibana/blob/main/x-pack/plugins/timelines/common/utils/accessibility/helpers.ts#L772 . What exactly is wrong with this? "The way this works should keep a logical and intuitive flow in keyboard navigation." is this not the case now?
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.
What exactly is wrong with this? "The way this works should keep a logical and intuitive flow in keyboard navigation." is this not the case now?
@kqualters-elastic this is what SharedUX team needs the @elastic/security-threat-hunting team to test and verify, because we don't know how to access all of the parts that this change could affect. The context is that this code needs to change because .chrHeaderLogo
is going away for cleanup purposes.
Let us know if you or a delegate can confirm that the functionality is not negatively impacted, or wish to see this modified in some way. Thanks!
@eokoneyo fully removing the class names had minimal effects. Can you re-review? |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
History
|
If it still applies, if class names are referenced in tests, convert to |
That part of the description is outdated. I will update. See also the thread here: #199885 (comment) |
Summary
Part of https://github.com/elastic/kibana-team/issues/1082
Selects certain Sass files to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components.
SomeUpdate: all classNames that are no longer needed for styling purposes have been removed.className
attributes have been kept, because they are referenced in JS and tests.References