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

feat(Popup): add disableTransition property #2114

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/Popup/Popup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ $transition-distance: 10px;
visibility: visible;
}

&_disable-transition {
transition: none;
}

& > :first-child:not(#{$block}__arrow),
& > #{$block}__arrow + * {
border-start-start-radius: inherit;
Expand Down
15 changes: 13 additions & 2 deletions src/components/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export interface PopupProps extends DOMProps, AriaLabelingProps, QAProps {
* Do not use as layer
*/
disableLayer?: boolean;
/** Disables animation of popup appearing/disappearing */
disableTransition?: boolean;
/** ARIA role or special component role (select, combobox) */
role?: UseRoleProps['role'];
/** HTML `id` attribute */
Expand Down Expand Up @@ -169,6 +171,7 @@ export function Popup({
children,
disablePortal = false,
disableLayer = false,
disableTransition = false,
qa,
role: roleProp,
zIndex = 1000,
Expand Down Expand Up @@ -259,7 +262,9 @@ export function Popup({

const {getFloatingProps} = useInteractions(floatingInteractions ?? [role, dismiss]);

const {isMounted, status} = useTransitionStatus(context, {duration: TRANSITION_DURATION});
const {isMounted, status} = useTransitionStatus(context, {
duration: disableTransition ? 0 : TRANSITION_DURATION,
});
const previousStatus = usePrevious(status);

React.useEffect(() => {
Expand Down Expand Up @@ -338,7 +343,13 @@ export function Popup({
>
<div
ref={contentRef}
className={b({open: isMounted}, className)}
className={b(
{
open: isMounted,
'disable-transition': disableTransition,
},
className,
)}
style={style}
data-qa={qa}
{...filterDOMProps(restProps)}
Expand Down
1 change: 1 addition & 0 deletions src/components/Popup/README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ LANDING_BLOCK-->
| disableFocusOut | Disables triggering close on focusout | `boolean` | `false` |
| disableOutsideClick | Disables triggering close on outside clicks | `boolean` | `false` |
| disablePortal | Disables using `Portal` for children | `boolean` | `false` |
| disableTransition | Disables animation of popup appearing/disappearing | `boolean` | `false` |
| floatingContext | `Floating UI` context to provide interactions | `FloatingRootContext` | |
| floatingInteractions | Override `Floating UI` interactions | `Array<ElementProps>` | |
| floatingMiddlewares | `Floating UI` middlewares. If set, they will completely overwrite the default middlewares. | `Array<Middleware>` | |
Expand Down
1 change: 1 addition & 0 deletions src/components/Popup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ LANDING_BLOCK-->
| disableFocusOut | Disables triggering close on focusout | `boolean` | `false` |
| disableOutsideClick | Disables triggering close on outside clicks | `boolean` | `false` |
| disablePortal | Disables using `Portal` for children | `boolean` | `false` |
| disableTransition | Disables animation of popup appearing/disappearing | `boolean` | `false` |
| floatingContext | `Floating UI` context to provide interactions | `FloatingRootContext` | |
| floatingInteractions | Override `Floating UI` interactions | `Array<ElementProps>` | |
| floatingMiddlewares | `Floating UI` middlewares. If set, they will completely overwrite the default middlewares. | `Array<Middleware>` | |
Expand Down
Loading