fix: fix dropdown buttons z-index (#1431)

Closes #1430, Closes #1422
This commit is contained in:
Thaïs 2023-09-04 16:51:12 +02:00 committed by GitHub
parent 96a0f30e98
commit 8e22ffd021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 22 deletions

View File

@ -1,4 +1,10 @@
import { Context, ReactNode, useCallback, useState } from 'react';
import {
type ComponentProps,
Context,
type ReactNode,
useCallback,
useState,
} from 'react';
import styled from '@emotion/styled';
import { DropdownRecoilScopeContext } from '@/ui/dropdown/states/recoil-scope-contexts/DropdownRecoilScopeContext';
@ -15,7 +21,7 @@ import { BoardOptionsHotkeyScope } from '../types/BoardOptionsHotkeyScope';
import { BoardOptionsDropdown } from './BoardOptionsDropdown';
type OwnProps<SortField> = {
type OwnProps<SortField> = ComponentProps<'div'> & {
viewName: string;
viewIcon?: ReactNode;
availableSorts?: Array<SortType<SortField>>;
@ -41,6 +47,7 @@ export function BoardHeader<SortField>({
onSortsUpdate,
onStageAdd,
context,
...props
}: OwnProps<SortField>) {
const [sorts, innerSetSorts] = useState<Array<SelectedSortType<SortField>>>(
[],
@ -67,6 +74,7 @@ export function BoardHeader<SortField>({
return (
<RecoilScope SpecificContext={DropdownRecoilScopeContext}>
<TopBar
{...props}
displayBottomBorder={false}
leftComponent={
<>

View File

@ -41,6 +41,11 @@ const StyledWrapper = styled.div`
width: 100%;
`;
const StyledBoardHeader = styled(BoardHeader)`
position: relative;
z-index: 1;
` as typeof BoardHeader;
export function EntityBoard({
boardOptions,
onColumnAdd,
@ -130,7 +135,7 @@ export function EntityBoard({
return (boardColumns?.length ?? 0) > 0 ? (
<StyledWrapper>
<BoardHeader
<StyledBoardHeader
viewName="All opportunities"
viewIcon={<IconList size={theme.icon.size.md} />}
availableSorts={boardOptions.sorts}

View File

@ -1,6 +1,5 @@
import { useEffect, useRef } from 'react';
import { Keys } from 'react-hotkeys-hook';
import styled from '@emotion/styled';
import { flip, offset, Placement, useFloating } from '@floating-ui/react';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
@ -13,11 +12,6 @@ import { useDropdownButton } from '../hooks/useDropdownButton';
import { dropdownButtonCustomHotkeyScopeScopedFamilyState } from '../states/dropdownButtonCustomHotkeyScopeScopedFamilyState';
import { DropdownRecoilScopeContext } from '../states/recoil-scope-contexts/DropdownRecoilScopeContext';
const StyledContainer = styled.div`
position: relative;
z-index: 100;
`;
type OwnProps = {
buttonComponents: JSX.Element | JSX.Element[];
dropdownComponents: JSX.Element | JSX.Element[];
@ -81,7 +75,7 @@ export function DropdownButton({
]);
return (
<StyledContainer ref={containerRef}>
<div ref={containerRef}>
{hotkey && (
<HotkeyEffect
hotkey={hotkey}
@ -94,6 +88,6 @@ export function DropdownButton({
{dropdownComponents}
</div>
)}
</StyledContainer>
</div>
);
}

View File

@ -22,8 +22,6 @@ type OwnProps = {
const StyledDropdownButtonContainer = styled.div`
display: flex;
flex-direction: column;
position: relative;
z-index: 1;
`;
const StyledDropdownButtonIcon = styled.div`

View File

@ -1,4 +1,4 @@
import { ReactNode, useCallback } from 'react';
import { type ComponentProps, type ReactNode, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import styled from '@emotion/styled';
import { useRecoilValue } from 'recoil';
@ -63,14 +63,20 @@ const StyledPageActionContainer = styled.div`
gap: ${({ theme }) => theme.spacing(2)};
`;
type OwnProps = {
type OwnProps = ComponentProps<'div'> & {
title: string;
hasBackButton?: boolean;
icon: ReactNode;
children?: JSX.Element | JSX.Element[];
};
export function PageHeader({ title, hasBackButton, icon, children }: OwnProps) {
export function PageHeader({
title,
hasBackButton,
icon,
children,
...props
}: OwnProps) {
const navigate = useNavigate();
const navigateBack = useCallback(() => navigate(-1), [navigate]);
@ -81,7 +87,7 @@ export function PageHeader({ title, hasBackButton, icon, children }: OwnProps) {
: navbarIconSize.desktop;
return (
<StyledTopBarContainer>
<StyledTopBarContainer {...props}>
<StyledLeftContainer>
{!isNavbarOpened && (
<StyledTopBarButtonContainer>

View File

@ -1,7 +1,7 @@
import { ReactNode } from 'react';
import type { ComponentProps, ReactNode } from 'react';
import styled from '@emotion/styled';
type OwnProps = {
type OwnProps = ComponentProps<'div'> & {
leftComponent?: ReactNode;
rightComponent?: ReactNode;
bottomComponent?: ReactNode;
@ -43,9 +43,10 @@ export function TopBar({
rightComponent,
bottomComponent,
displayBottomBorder = true,
...props
}: OwnProps) {
return (
<StyledContainer>
<StyledContainer {...props}>
<StyledTopBar displayBottomBorder={displayBottomBorder}>
<StyledLeftSection>{leftComponent}</StyledLeftSection>
<StyledRightSection>{rightComponent}</StyledRightSection>

View File

@ -1,5 +1,6 @@
import { useCallback, useState } from 'react';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { HooksCompanyBoard } from '@/companies/components/HooksCompanyBoard';
import { CompanyBoardRecoilScopeContext } from '@/companies/states/recoil-scope-contexts/CompanyBoardRecoilScopeContext';
@ -24,6 +25,11 @@ import {
} from '~/generated/graphql';
import { opportunitiesBoardOptions } from '~/pages/opportunities/opportunitiesBoardOptions';
const StyledPageHeader = styled(PageHeader)`
position: relative;
z-index: 2;
`;
export function Opportunities() {
const theme = useTheme();
@ -74,14 +80,14 @@ export function Opportunities() {
return (
<PageContainer>
<RecoilScope>
<PageHeader
<StyledPageHeader
title="Opportunities"
icon={<IconTargetArrow size={theme.icon.size.md} />}
>
<RecoilScope SpecificContext={DropdownRecoilScopeContext}>
<PipelineAddButton />
</RecoilScope>
</PageHeader>
</StyledPageHeader>
<PageBody>
<BoardOptionsContext.Provider value={opportunitiesBoardOptions}>
<RecoilScope SpecificContext={CompanyBoardRecoilScopeContext}>