Skip to content

Conversation

@sg00dwin
Copy link
Contributor

@sg00dwin sg00dwin commented Apr 9, 2025

Feature #6603

This expand behavior is based off @mcokers POC codepen using scale transition for the search input that. It's set to display: none in the collapsed state.

To see the animation, use the chrome dev tools to toggle the pf-m-expanded modifier class. (Note: at closed state the X button will display because it requires the react component to switch the displayed icon to the magnifying glass.
Screenshot 2025-05-05 at 1 58 14 PM

These changes key off a pf-v6-c-input-group__search-expandable class along with modifier pf-m-expanded added to the <SearchInput... component.

The expanded text input uses an abbreviated scale(.7) value to transition from partial to full width scale(1) and by default the transition-origin direction is from left to right. Adding a pf-m-expand-left modifier will set the transition-origin to transition from right to left.

These changes necessitate a few changes to the React component.

In the “collapsed” state, an <InputGroupItem className="pf-v6-c-search-input">{buildTextInputGroup()}</InputGroupItem> is included with toggle button https://github.com/patternfly/patternfly-react/blob/main/packages/react-core/src/components/SearchInput/SearchInput.tsx#L415-L417 Without the pf-m-expanded and pf-m-fill classes and will be set to display:none

Additional changes: The close button icon opacity fade-in specified in @keyframes animation-name: #{$input-group}-expandable-fade-in could be replaced by a generic fade mixin that is proposed for inclusion with this PR.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Apr 9, 2025

@kmcfaul kmcfaul linked an issue Apr 10, 2025 that may be closed by this pull request
@sg00dwin sg00dwin force-pushed the 6603-search-input-animation branch 2 times, most recently from 63bdb13 to 294fbbb Compare May 5, 2025 21:56
@sg00dwin
Copy link
Contributor Author

sg00dwin commented May 6, 2025

@mcoker Please take another look

@sg00dwin sg00dwin force-pushed the 6603-search-input-animation branch from 294fbbb to 091e1d8 Compare May 9, 2025 20:08
@sg00dwin
Copy link
Contributor Author

search-input-expandable.mov

@sg00dwin sg00dwin force-pushed the 6603-search-input-animation branch from 091e1d8 to 52b11ed Compare May 19, 2025 14:50
Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

We should probably document the new classes.
Also, can we use $pf-prefix on the .pf-v6-c- classes here or no?
Otherwise, looks this looks good.

@sg00dwin
Copy link
Contributor Author

I pushed updates to use $pf-prefix

@sg00dwin sg00dwin force-pushed the 6603-search-input-animation branch from a986519 to 2932db9 Compare May 27, 2025 18:19
Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

Once the generic mixin is merged, it would be great to use it here too but otherwise,
L🔍TM!

@andrew-ronaldson
Copy link
Collaborator

I noticed the search icon shifts a bit in Chrome. It seems fine in both safari and Firefox.

Not a big deal but wanted to let you know

Screen.Recording.2025-05-27.at.5.06.49.PM.mov

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

LGTM though left some comments

width: 100%;
}

.#{$input-group}-expandable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this isn't .pf-m-expandable? You could also call it .pf-m-search-input, which might be more appropriate since IMO this needs some kind of modifier like that as it's a unique react component. That also gives us the room to use .pf-m-expandable later for a generally expandable input group.

}
}

.#{$pf-prefix}c-search-input {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this isn't a component, it should probably be .pf-v6-c-input-group__item.pf-m-search-input but if you used .pf-m-search-input on the outer wrapper, it would probably be better to use something different here. Maybe .pf-v6-c-input-group__item.pf-m-search-text-input? We have a #{$text-input-group}__text-input so I I think .pf-m-search-text-input would be fine.

opacity: 0;
transition-timing-function: var(--#{$input-group}-expandable__search-input--TransitionTimingFunction--collapse);
transition-duration: var(--#{$input-group}-expandable__search-input--TransitionDuration--collapse);
transition-property: opacity, scale, display;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of transitioning display, can you transition visibility and width to hide it? Then it will work x-browser without needing allow-discrete and @starting-style

Comment on lines 94 to 96
animation-name: #{$input-group}-expandable-fade;
animation-duration: var(--#{$input-group}-expandable__button-icon--TransitionDuration--Opacity);
animation-timing-function: var(--#{$input-group}-expandable__button-icon--TransitionTimingFunction--Opacity);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way this can be a transition so it doesn't run on page load?

@sg00dwin
Copy link
Contributor Author

sg00dwin commented Jun 10, 2025

@mcoker @thatblindgeye
With the new button click animation additions, the expandable search button now shows the click animation when going between the closed and expanded states. Presumably it's because the SearchInput component uses one button to handle both states and the component structure would need to be reworked to have separate buttons for each state?

Here's a slowed down example to show what is happening. Note that the click animation isn't triggered when using keyboard navigation.

Screen.Recording.2025-06-10.at.10.03.06.AM.mov

@mcoker mcoker force-pushed the 6603-search-input-animation branch from 3bd693b to 7f895a1 Compare June 12, 2025 20:30
@mcoker mcoker requested review from mcoker and srambach June 12, 2025 20:35
@mcoker
Copy link
Contributor

mcoker commented Jun 13, 2025

To test this, just toggle the .pf-m-expanded class on the search input group expandable examples.

I added the docs for the new classes and hwhat-not under the input group - https://patternfly-pr-7451.surge.sh/components/input-group#usage. I'm not sure if that's the right place for them... Technically the classes apply to input group elements, but the example is listed under text input group (in core anyways, it's its own component in react). So I listed the docs under input group for now with a note that the examples are under text input group and the search input component pages. Let me know if anyone feels strongly about changing that and I'll update it.

mcoker and others added 2 commits June 13, 2025 13:24
…up.md

Co-authored-by: Sarah Rambacher <srambach@redhat.com>
Co-authored-by: Sarah Rambacher <srambach@redhat.com>
Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

Looks like something messed up the collapsed view?
image

@mcoker mcoker requested a review from srambach June 13, 2025 18:29
Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

🔍 GTM!

@mcoker mcoker merged commit 29561ce into patternfly:main Jun 16, 2025
4 checks passed
@patternfly-build
Copy link
Collaborator

🎉 This PR is included in version 6.3.0-prerelease.32 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search input: Animating Transitions and expandable inputs

5 participants