-
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
[Global search bar] Fix clear button glitch #137251
[Global search bar] Fix clear button glitch #137251
Conversation
Pinging @elastic/kibana-core (Team:Core) |
Search bar behaviour after the fix: Screen.Recording.2022-07-27.at.11.04.17.mov |
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.
@gsoldevila Thanks for making the PR. A couple of quick comments.
}, | ||
fullWidth: true, | ||
append: showAppend ? ( | ||
<EuiFormLabel | ||
title={keyboardShortcutTooltip} | ||
css={{ fontFamily: euiTheme.font.familyCode }} | ||
css={{ fontFamily: euiTheme.font.familyCode, position: 'absolute', right: 0 }} |
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.
Why is the absolute positioning necessary?
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.
For context, we are adding / removing the component onBlur
and onFocus
respectively, so that the shortcut hint is only visible when the search bar is not already focussed.
The absolute positioning is necessary so that when removing / adding back the append component it does not affect the parent container's size.
This way we completely avoid a small layout shift that is visually disturbing.
Behaviour without the absolute positioning (you can compare with the video demoing the complete fix, above):
Screen.Recording.2022-07-27.at.15.27.01.mov
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.
This is because the width is being applied at the search input instead of the overall wrapping element. I'll describe the fix a review 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.
Then you can delete this absolute positioning.
css={{ fontFamily: euiTheme.font.familyCode, position: 'absolute', right: 0 }} | |
css={{ fontFamily: euiTheme.font.familyCode }} |
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.
Move line 295 where the className is set within searchProps
to the top level component, ~line 283. Since we no longer need to apply styles based on :focus
state, we can just set the width for the entire component which will ensure the append
is included in that width.
+ className="kbnSearchBar"
searchProps={{
...
- className: 'kbnSearchBar',
}}
And remove lines 17-21 in the Sass file because they were required solely for the animation.
-//TODO add these overrides to EUI so that search behaves the same globally (eui/issues/4363)
-.kbnSearchBar {
- max-width: 100%;
- will-change: width;
-}
}, | ||
fullWidth: true, | ||
append: showAppend ? ( | ||
<EuiFormLabel | ||
title={keyboardShortcutTooltip} | ||
css={{ fontFamily: euiTheme.font.familyCode }} | ||
css={{ fontFamily: euiTheme.font.familyCode, position: 'absolute', right: 0 }} |
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.
Then you can delete this absolute positioning.
css={{ fontFamily: euiTheme.font.familyCode, position: 'absolute', right: 0 }} | |
css={{ fontFamily: euiTheme.font.familyCode }} |
Thanks a lot for the suggestions, much cleaner approach! I see a small flickering issue caused by the append component being immediately black, whereas the rest of the search bar fades to black gradually, but I guess we can live with that: Screen.Recording.2022-07-27.at.17.50.48.mov |
x-pack/plugins/global_search_bar/public/components/search_bar.scss
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
Metrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: |
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.
Code & screen grabs LGTM, I didn't specifically pull down to test but quickly tried out a similar implementation in local EUI.
* Fix global search bar clear button glitch * Fix small layout shift caused by "append" disappearing on hover * Apply @cchaos 's suggestions * Update x-pack/plugins/global_search_bar/public/components/search_bar.scss Co-authored-by: Caroline Horn <[email protected]> Co-authored-by: Caroline Horn <[email protected]> (cherry picked from commit f2a14e2)
* Fix global search bar clear button glitch * Fix small layout shift caused by "append" disappearing on hover * Apply @cchaos 's suggestions * Update x-pack/plugins/global_search_bar/public/components/search_bar.scss Co-authored-by: Caroline Horn <[email protected]> Co-authored-by: Caroline Horn <[email protected]> (cherry picked from commit f2a14e2)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
* Fix global search bar clear button glitch * Fix small layout shift caused by "append" disappearing on hover * Apply @cchaos 's suggestions * Update x-pack/plugins/global_search_bar/public/components/search_bar.scss Co-authored-by: Caroline Horn <[email protected]> Co-authored-by: Caroline Horn <[email protected]> (cherry picked from commit f2a14e2) Co-authored-by: Gerard Soldevila <[email protected]>
* Fix global search bar clear button glitch * Fix small layout shift caused by "append" disappearing on hover * Apply @cchaos 's suggestions * Update x-pack/plugins/global_search_bar/public/components/search_bar.scss Co-authored-by: Caroline Horn <[email protected]> Co-authored-by: Caroline Horn <[email protected]> (cherry picked from commit f2a14e2) Co-authored-by: Gerard Soldevila <[email protected]>
Fixes #135529
The PR fixes 2 glitches:
⌘/
shortcut hint) if the user has already entered some text. This is also a source of layout shift that causes the user to miss the clear button on click.See discussion on #135529 for more information.
@elastic/kibana-design can you confirm you are okay with these changes?