Skip to content

Prevent jumping of search button#66929

Open
sarthaknagoshe2002 wants to merge 2 commits intoWordPress:trunkfrom
sarthaknagoshe2002:fix/Button-position-jumps
Open

Prevent jumping of search button#66929
sarthaknagoshe2002 wants to merge 2 commits intoWordPress:trunkfrom
sarthaknagoshe2002:fix/Button-position-jumps

Conversation

@sarthaknagoshe2002
Copy link
Copy Markdown
Contributor

@sarthaknagoshe2002 sarthaknagoshe2002 commented Nov 12, 2024

Fixes: #52854

What?

When the search box has change button position set to button only and is aligned to the right while having blocks to it left, the search button jumps, highlighted in #52854.
This PR fixes this jumping of search button when the search box expands.

How?

Removed flex-basis property from the input box which was making the button jump.

Testing Instructions

  1. Add/edit existing post.
  2. Add a row.
  3. Add some blocks on the left side of the row.
  4. Add the search block to the right.
  5. Set change button position to button only.
  6. On the frontend the search button should no longer jump while expanding the search box.

Screenshots or screencast

Before

Screen.Recording.2024-11-12.at.5.30.57.PM.mov

After

Screen.Recording.2024-11-12.at.5.31.25.PM.mov

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 12, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sarthaknagoshe2002 <sarthaknagoshe2002@git.wordpress.org>
Co-authored-by: yashjawale <yashjawale@git.wordpress.org>
Co-authored-by: skorasaurus <skorasaurus@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 12, 2024
@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @sarthaknagoshe2002! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@akasunil akasunil added [Type] Bug An existing feature does not function as intended [Block] Search Affects the Search Block - used to display a search field labels Nov 12, 2024
@yashjawale
Copy link
Copy Markdown
Contributor

Thanks for the PR 🙌
However, I noticed that the transition isn't visible in the middle, this is especially visible when we increase transition duration

Screen.Recording.2025-06-18.at.1.13.48.PM.mov

The fixes suggested by @EldarAgalarov in 70450 might be helpful...

}

.wp-block-search__input {
transition-duration: 300ms;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding... adding an explicit default width here

Suggested change
transition-duration: 300ms;
transition-duration: 300ms;
width: 250px;

And setting flex-basis to 100% for .wp-block-search__input here should help to achieve the desired effect...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think setting default width is a good idea considering the fact the this block's width can be set by the user manually. Are you sure that the DOM would handle it in the right & efficient way when user set the width of the search block? incase if we agree to this approach then should there be a fallback when enough room is not available for the block?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing, overrides from dashboard still work. Without explicit width the transition don't seem to work.
But yes it can cause issues when sufficient room isn't available (have to check how the current implementation handles this case)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it does not works as expected when enough room is not available then in that case maybe we will have to choose not setting the default width over prioritising the transition, otherwise your suggestion is the best approach that we should proceed with😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Search Affects the Search Block - used to display a search field First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search: Button only: Button position jumps on transition

3 participants