Skip to content
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

Conversation

gsoldevila
Copy link
Contributor

@gsoldevila gsoldevila commented Jul 27, 2022

Fixes #135529

The PR fixes 2 glitches:

  • Removing the 400px => 600px expand animation on focus (which shrinks back to 400px on blur). The blur event happens before the click, so we're actually losing the click on the clear button (plus layout shift on user action is usually something we want to avoid).
  • Hiding the append button (⌘/ 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?

@gsoldevila gsoldevila requested review from a team as code owners July 27, 2022 08:02
@gsoldevila gsoldevila added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:fix backport:all-open Backport to all branches that could still receive a release labels Jul 27, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@gsoldevila gsoldevila added v8.5.0 bug Fixes for quality problems that affect the customer experience labels Jul 27, 2022
@gsoldevila
Copy link
Contributor Author

Search bar behaviour after the fix:

Screen.Recording.2022-07-27.at.11.04.17.mov

Copy link
Contributor

@cchaos cchaos left a 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 }}
Copy link
Contributor

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?

Copy link
Contributor Author

@gsoldevila gsoldevila Jul 27, 2022

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Suggested change
css={{ fontFamily: euiTheme.font.familyCode, position: 'absolute', right: 0 }}
css={{ fontFamily: euiTheme.font.familyCode }}

@gsoldevila gsoldevila changed the title Fix global search bar clear button glitch [Global search bar] Fix clear button glitch Jul 27, 2022
@gsoldevila gsoldevila requested a review from cchaos July 27, 2022 13:30
Copy link
Contributor

@cchaos cchaos left a 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 }}
Copy link
Contributor

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.

Suggested change
css={{ fontFamily: euiTheme.font.familyCode, position: 'absolute', right: 0 }}
css={{ fontFamily: euiTheme.font.familyCode }}

@gsoldevila
Copy link
Contributor Author

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

@gsoldevila gsoldevila requested a review from cchaos July 27, 2022 16:15
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
globalSearchBar 21.1KB 20.5KB -683.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@gsoldevila gsoldevila requested a review from cchaos July 28, 2022 11:09
@gsoldevila gsoldevila enabled auto-merge (squash) July 28, 2022 11:10
Copy link
Contributor

@cchaos cchaos left a 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.

@gsoldevila gsoldevila merged commit f2a14e2 into elastic:main Jul 28, 2022
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 28, 2022
* 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)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 28, 2022
* 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)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
7.17 Backport failed because of merge conflicts
8.3
8.4

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 137251

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jul 28, 2022
* 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]>
kibanamachine added a commit that referenced this pull request Jul 28, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:all-open Backport to all branches that could still receive a release bug Fixes for quality problems that affect the customer experience release_note:fix Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.3.3 v8.4.0 v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Global Search] The "clear" button makes the search to lose focus
6 participants