Skip to content

Commit

Permalink
fix(Popper): add support of prop zIndex (#8091)
Browse files Browse the repository at this point in the history
* feat(Popper): add support of prop zIndex

* fix(Popper): make with mergeStyle
  • Loading branch information
EldarMuhamethanov authored Dec 17, 2024
1 parent 8301011 commit b5f950e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/vkui/src/components/Popper/Popper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import * as React from 'react';
import { mergeStyle } from '../../helpers/mergeStyle';
import { useExternRef } from '../../hooks/useExternRef';
import {
autoUpdateFloatingElement,
Expand Down Expand Up @@ -113,6 +114,8 @@ export const Popper = ({
children,
usePortal = true,
onPlacementChange,
zIndex,
style,
...restProps
}: PopperProps): React.ReactNode => {
const [arrowRef, setArrowRef] = React.useState<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -159,9 +162,17 @@ export const Popper = ({
refs.setReference('current' in targetRef ? targetRef.current : targetRef);
}, [refs.setReference, targetRef]);

const dropdownStyle =
typeof zIndex !== 'undefined'
? {
zIndex,
}
: undefined;

const dropdown = (
<RootComponent
{...restProps}
style={mergeStyle(dropdownStyle, style)}
baseClassName={styles.host}
getRootRef={handleRootRef}
baseStyle={convertFloatingDataToReactCSSProperties(
Expand Down

0 comments on commit b5f950e

Please sign in to comment.