Add the role=button to search (#7594)
In this PR: - Let the `<NavigationDrawerItem />` component render a `<button>` by default instead of a `<div>` - Replace `<div>` by `<span>` inside the `<NavigationDrawerItem />` as `<button>` and `<a>` HTML elements only accept [_phrasing content_](https://developer.mozilla.org/en-US/docs/Web/HTML/Content_categories#phrasing_content). - Fix layout issue: the keyboard icon wasn't put on the right of the button, I put it back Fixes #7575 --------- Co-authored-by: Devessier <baptiste@devessier.fr>
This commit is contained in:
@ -5,7 +5,9 @@ import styled from '@emotion/styled';
|
|||||||
import { AnimationControls, motion, TargetAndTransition } from 'framer-motion';
|
import { AnimationControls, motion, TargetAndTransition } from 'framer-motion';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
const StyledAnimatedContainer = styled(motion.div)``;
|
const StyledAnimatedContainer = styled(motion.span)`
|
||||||
|
display: block;
|
||||||
|
`;
|
||||||
|
|
||||||
export const NavigationDrawerAnimatedCollapseWrapper = ({
|
export const NavigationDrawerAnimatedCollapseWrapper = ({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
|
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
|
||||||
|
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
|
||||||
import { NavigationDrawerItemBreadcrumb } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemBreadcrumb';
|
import { NavigationDrawerItemBreadcrumb } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemBreadcrumb';
|
||||||
|
import { NAV_DRAWER_WIDTHS } from '@/ui/navigation/navigation-drawer/constants/NavDrawerWidths';
|
||||||
import { NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerSubItemState';
|
import { NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerSubItemState';
|
||||||
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
|
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
|
||||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||||
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
|
|
||||||
import isPropValid from '@emotion/is-prop-valid';
|
import isPropValid from '@emotion/is-prop-valid';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
@ -16,8 +18,6 @@ import {
|
|||||||
TablerIconsProps,
|
TablerIconsProps,
|
||||||
} from 'twenty-ui';
|
} from 'twenty-ui';
|
||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
|
|
||||||
import { NAV_DRAWER_WIDTHS } from '@/ui/navigation/navigation-drawer/constants/NavDrawerWidths';
|
|
||||||
|
|
||||||
const DEFAULT_INDENTATION_LEVEL = 1;
|
const DEFAULT_INDENTATION_LEVEL = 1;
|
||||||
|
|
||||||
@ -43,10 +43,11 @@ type StyledItemProps = Pick<
|
|||||||
'active' | 'danger' | 'indentationLevel' | 'soon' | 'to'
|
'active' | 'danger' | 'indentationLevel' | 'soon' | 'to'
|
||||||
> & { isNavigationDrawerExpanded: boolean };
|
> & { isNavigationDrawerExpanded: boolean };
|
||||||
|
|
||||||
const StyledItem = styled('div', {
|
const StyledItem = styled('button', {
|
||||||
shouldForwardProp: (prop) =>
|
shouldForwardProp: (prop) =>
|
||||||
!['active', 'danger', 'soon'].includes(prop) && isPropValid(prop),
|
!['active', 'danger', 'soon'].includes(prop) && isPropValid(prop),
|
||||||
})<StyledItemProps>`
|
})<StyledItemProps>`
|
||||||
|
box-sizing: content-box;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: ${(props) =>
|
background: ${(props) =>
|
||||||
props.active ? props.theme.background.transparent.light : 'inherit'};
|
props.active ? props.theme.background.transparent.light : 'inherit'};
|
||||||
@ -103,19 +104,20 @@ const StyledItem = styled('div', {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledItemElementsContainer = styled.div`
|
const StyledItemElementsContainer = styled.span`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: ${({ theme }) => theme.spacing(2)};
|
gap: ${({ theme }) => theme.spacing(2)};
|
||||||
|
width: 100%;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledItemLabel = styled.div`
|
const StyledItemLabel = styled.span`
|
||||||
font-weight: ${({ theme }) => theme.font.weight.medium};
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledItemCount = styled.div`
|
const StyledItemCount = styled.span`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: ${({ theme }) => theme.color.blue};
|
background-color: ${({ theme }) => theme.color.blue};
|
||||||
border-radius: ${({ theme }) => theme.border.radius.rounded};
|
border-radius: ${({ theme }) => theme.border.radius.rounded};
|
||||||
@ -129,7 +131,7 @@ const StyledItemCount = styled.div`
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledKeyBoardShortcut = styled.div`
|
const StyledKeyBoardShortcut = styled.span`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
color: ${({ theme }) => theme.font.color.light};
|
color: ${({ theme }) => theme.font.color.light};
|
||||||
@ -140,11 +142,15 @@ const StyledKeyBoardShortcut = styled.div`
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledNavigationDrawerItemContainer = styled.div`
|
const StyledNavigationDrawerItemContainer = styled.span`
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StyledSpacer = styled.span`
|
||||||
|
flex-grow: 1;
|
||||||
|
`;
|
||||||
|
|
||||||
export const NavigationDrawerItem = ({
|
export const NavigationDrawerItem = ({
|
||||||
className,
|
className,
|
||||||
label,
|
label,
|
||||||
@ -191,7 +197,7 @@ export const NavigationDrawerItem = ({
|
|||||||
aria-selected={active}
|
aria-selected={active}
|
||||||
danger={danger}
|
danger={danger}
|
||||||
soon={soon}
|
soon={soon}
|
||||||
as={to ? Link : 'div'}
|
as={to ? Link : undefined}
|
||||||
to={to ? to : undefined}
|
to={to ? to : undefined}
|
||||||
indentationLevel={indentationLevel}
|
indentationLevel={indentationLevel}
|
||||||
isNavigationDrawerExpanded={isNavigationDrawerExpanded}
|
isNavigationDrawerExpanded={isNavigationDrawerExpanded}
|
||||||
@ -219,6 +225,8 @@ export const NavigationDrawerItem = ({
|
|||||||
<StyledItemLabel>{label}</StyledItemLabel>
|
<StyledItemLabel>{label}</StyledItemLabel>
|
||||||
</NavigationDrawerAnimatedCollapseWrapper>
|
</NavigationDrawerAnimatedCollapseWrapper>
|
||||||
|
|
||||||
|
<StyledSpacer />
|
||||||
|
|
||||||
{soon && (
|
{soon && (
|
||||||
<NavigationDrawerAnimatedCollapseWrapper>
|
<NavigationDrawerAnimatedCollapseWrapper>
|
||||||
<Pill label="Soon" />
|
<Pill label="Soon" />
|
||||||
|
|||||||
Reference in New Issue
Block a user