-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[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!
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 I will test this tomorrow..
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.
Okay I did some desk testing with the new change and there are couple of issues with this change.
- Although body is focusable, it is not tabbable which actually takes user out of
tab
order and if once the focus isreset
onbody
, pressingTab
after that does nothing. - In previous case, the reset was focusing the logo, which was kind of
first
in the tab order and users can now tab through out the page which is not possible in the new change. - It looks like, this function ( old version, not the change) is broken in serverless, since logo with class
chrHeaderLogo
does not even exists in Serverless.- this begs the question, if we even need this functionality. I will discuss with the team today and if we do not, i will push the commit to remove it.
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 @logeekal!
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 Does this PR need to be held on the discussion with your team? I hope not, and I think that if nothing else is blocking this PR, it could get approved and the team discussion could be handled as follow-up work.
Does that sound ok?
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.
@tsullivan , Sorry for the delay from my side. It took time to get full information, but i can say that this piece of code is not required at our end. But I will create a separate PR to remove it so that you are not blocked.
I will create a separate PR to add that code. Thanks for your patience.
@eokoneyo fully removing the class names had minimal effects. Can you re-review? |
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) |
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.
investigations LGTM 🚀 . Thanks for answering all our queries.
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
|
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.
LGTM
Starting backport for target branches: 8.x |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Part of elastic/kibana-team#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. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]> (cherry picked from commit d86896b)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Part of elastic/kibana-team#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. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
## Summary Part of elastic/kibana-team#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. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
# Backport This will backport the following commits from `main` to `8.x`: - [[SharedUX] Replace Sass with Emotion, Round 1 (#199885)](#199885) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Tim Sullivan","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-04T17:39:22Z","message":"[SharedUX] Replace Sass with Emotion, Round 1 (#199885)\n\n## Summary\r\n\r\nPart of https://github.com/elastic/kibana-team/issues/1082\r\n\r\nSelects certain Sass files to replace with styles declared with Emotion.\r\nThis PR does not include any changes that would be noticeable by\r\nend-users. It changes the internals to use a different technology for\r\nstyling components.\r\n\r\n~~Some `className` attributes have been kept, because they are\r\nreferenced in JS and tests.~~ Update: all classNames that are no longer\r\nneeded for styling purposes have been removed.\r\n* If the className was needed for tests, it has been replaced with a\r\ntest-subj.\r\n* If the className was used as a selector in production code, it has\r\nbeen replaced with alternative JS.\r\n\r\n## References\r\n1. https://emotion.sh/docs/globals\r\n2. https://emotion.sh/docs/best-practices\r\n3.\r\nhttps://github.com/elastic/eui/discussions/6828#discussioncomment-10825360\r\n\r\n---------\r\n\r\nCo-authored-by: Jatin Kathuria <[email protected]>","sha":"d86896bac0bbc5ed48b43e695e0a73c55b21450c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","v9.0.0","backport:prev-minor"],"number":199885,"url":"https://github.com/elastic/kibana/pull/199885","mergeCommit":{"message":"[SharedUX] Replace Sass with Emotion, Round 1 (#199885)\n\n## Summary\r\n\r\nPart of https://github.com/elastic/kibana-team/issues/1082\r\n\r\nSelects certain Sass files to replace with styles declared with Emotion.\r\nThis PR does not include any changes that would be noticeable by\r\nend-users. It changes the internals to use a different technology for\r\nstyling components.\r\n\r\n~~Some `className` attributes have been kept, because they are\r\nreferenced in JS and tests.~~ Update: all classNames that are no longer\r\nneeded for styling purposes have been removed.\r\n* If the className was needed for tests, it has been replaced with a\r\ntest-subj.\r\n* If the className was used as a selector in production code, it has\r\nbeen replaced with alternative JS.\r\n\r\n## References\r\n1. https://emotion.sh/docs/globals\r\n2. https://emotion.sh/docs/best-practices\r\n3.\r\nhttps://github.com/elastic/eui/discussions/6828#discussioncomment-10825360\r\n\r\n---------\r\n\r\nCo-authored-by: Jatin Kathuria <[email protected]>","sha":"d86896bac0bbc5ed48b43e695e0a73c55b21450c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199885","number":199885,"mergeCommit":{"message":"[SharedUX] Replace Sass with Emotion, Round 1 (#199885)\n\n## Summary\r\n\r\nPart of https://github.com/elastic/kibana-team/issues/1082\r\n\r\nSelects certain Sass files to replace with styles declared with Emotion.\r\nThis PR does not include any changes that would be noticeable by\r\nend-users. It changes the internals to use a different technology for\r\nstyling components.\r\n\r\n~~Some `className` attributes have been kept, because they are\r\nreferenced in JS and tests.~~ Update: all classNames that are no longer\r\nneeded for styling purposes have been removed.\r\n* If the className was needed for tests, it has been replaced with a\r\ntest-subj.\r\n* If the className was used as a selector in production code, it has\r\nbeen replaced with alternative JS.\r\n\r\n## References\r\n1. https://emotion.sh/docs/globals\r\n2. https://emotion.sh/docs/best-practices\r\n3.\r\nhttps://github.com/elastic/eui/discussions/6828#discussioncomment-10825360\r\n\r\n---------\r\n\r\nCo-authored-by: Jatin Kathuria <[email protected]>","sha":"d86896bac0bbc5ed48b43e695e0a73c55b21450c"}}]}] BACKPORT-->
## Summary Part of elastic/kibana-team#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. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
## Summary Part of elastic/kibana-team#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. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
## Summary Part of elastic/kibana-team#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. ~~Some `className` attributes have been kept, because they are referenced in JS and tests.~~ Update: all classNames that are no longer needed for styling purposes have been removed. * If the className was needed for tests, it has been replaced with a test-subj. * If the className was used as a selector in production code, it has been replaced with alternative JS. ## References 1. https://emotion.sh/docs/globals 2. https://emotion.sh/docs/best-practices 3. elastic/eui#6828 (comment) --------- Co-authored-by: Jatin Kathuria <[email protected]>
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