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

View File

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

View File

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

View File

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

View File

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

View File

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