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

feature / add the prop tabIndex on componente when aria hiden is true #85

Merged
4 changes: 1 addition & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"extends": "vtex",
"root": true,
"env": {
"node": true,
"es6": true,
"jest": true
"node": true
}
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed
- Only show `aria` when menu is closed

## [0.18.1] - 2024-11-14

### Added
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"eslint --fix",
"prettier --write"
],
"*.{json,graphql,gql}": [
"prettier --write"
],
"*.json": [
"prettier --write"
]
Expand Down
31 changes: 20 additions & 11 deletions react/Drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {

Check warning on line 1 in react/Drawer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Import "MouseEventHandler" is only used as types
Suspense,
useReducer,
MouseEventHandler,
Expand All @@ -11,8 +11,8 @@
import { useCssHandles } from 'vtex.css-handles'
import { useChildBlock, ExtensionPoint } from 'vtex.render-runtime'
import { usePixelEventCallback } from 'vtex.pixel-manager'
import { PixelData } from 'vtex.pixel-manager/react/PixelContext'
import type { PixelEventTypes } from 'vtex.pixel-manager'

Check failure on line 14 in react/Drawer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Parsing error: '=' expected
import {

Check warning on line 15 in react/Drawer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Import "MaybeResponsiveValue" is only used as types
MaybeResponsiveValue,
useResponsiveValue,
} from 'vtex.responsive-values'
Expand Down Expand Up @@ -61,8 +61,8 @@
header?: React.ReactElement
backdropMode?: MaybeResponsiveValue<BackdropMode>
renderingStrategy?: RenderingStrategy
customPixelEventId?: PixelData['id']
customPixelEventName?: PixelData['event']
customPixelEventId?: PixelEventTypes.PixelData['id']
customPixelEventName?: PixelEventTypes.PixelData['event']
onVisibilityChanged?: (visible: boolean) => void
zIndex?: number
}
Expand All @@ -75,12 +75,12 @@
isOpen: true,
hasBeenOpened: true,
}
case 'close':

Check warning on line 78 in react/Drawer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Expected blank line before this statement
return {
...state,
isOpen: false,
}
default:

Check warning on line 83 in react/Drawer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Expected blank line before this statement
return state
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@
onVisibilityChanged,
zIndex = 999,
} = props
const handles = useCssHandles(CSS_HANDLES)

Check warning on line 134 in react/Drawer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Expected blank line before this statement
const backdropMode = useResponsiveValue(backdropModeProp)
const hasTriggerBlock = Boolean(useChildBlock({ id: 'drawer-trigger' }))
const hasHeaderBlock = Boolean(useChildBlock({ id: 'drawer-header' }))
Expand All @@ -140,7 +140,7 @@
const [shouldRenderChildren, setShouldRenderChildren] = useState(
renderingStrategy === 'eager'
)
const [isMoving, setIsMoving] = useState(false)

Check warning on line 143 in react/Drawer.tsx

View workflow job for this annotation

GitHub Actions / Lint

Expected blank line before this statement

// Always add the listener for 'openDrawer' events, since they're sent by
// the drawer-trigger block.
Expand Down Expand Up @@ -204,10 +204,21 @@
return (
<DrawerContextProvider value={contextValue}>
<div
onClick={openMenu}
role="presentation"
role="button"
aria-hidden={isMenuOpen ? 'false' : 'true'}
className={`pa4 pointer ${handles.openIconContainer}`}
aria-expanded={isMenuOpen}
aria-label={isMenuOpen ? 'close drawer' : 'open drawer'}
tabIndex={isMenuOpen ? 0 : -1}
onClick={openMenu}
onKeyDown={e => {
if (
isMenuOpen &&
(e.key === 'Enter' || e.key === ' ' || e.key === 'Escape')
) {
e.preventDefault()
openMenu()
}
}}
>
{hasTriggerBlock ? (
<ExtensionPoint id="drawer-trigger" />
Expand All @@ -228,11 +239,9 @@
onUpdateOffset={value => {
setIsMoving(!(value === '0%' || value === '-100%'))
}}
className={`${handles.drawer} ${
isMenuOpen ? handles.opened : handles.closed
} ${isMoving ? handles.moving : ''} ${
direction === 'right' ? 'right-0' : 'left-0'
} fixed top-0 bottom-0 bg-base z-999 flex flex-column`}
className={`${handles.drawer} ${isMenuOpen ? handles.opened : handles.closed
} ${isMoving ? handles.moving : ''} ${direction === 'right' ? 'right-0' : 'left-0'
} fixed top-0 bottom-0 bg-base z-999 flex flex-column`}
style={{
width: width ?? (isFullWidth ? '100%' : '85%'),
maxWidth,
Expand Down
4 changes: 2 additions & 2 deletions react/DrawerTrigger.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FC } from 'react'

Check warning on line 1 in react/DrawerTrigger.tsx

View workflow job for this annotation

GitHub Actions / Lint

Import "FC" is only used as types
import { usePixel } from 'vtex.pixel-manager'
import { PixelData } from 'vtex.pixel-manager/react/PixelContext'
import type { PixelEventTypes } from 'vtex.pixel-manager'

Check failure on line 3 in react/DrawerTrigger.tsx

View workflow job for this annotation

GitHub Actions / Lint

Parsing error: '=' expected
import { useCssHandles } from 'vtex.css-handles'

interface Props {
Expand All @@ -18,7 +18,7 @@
return
}

const pixelEvent: PixelData = {
const pixelEvent: PixelEventTypes.PixelData = {
id: customPixelEventId,
event: 'openDrawer',
}
Expand Down
8 changes: 4 additions & 4 deletions react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"@vtex/test-tools": "^3.0.0",
"typescript": "3.9.7",
"vtex.css-handles": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.4/public/@types/vtex.css-handles",
"vtex.pixel-manager": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-manager@1.4.0/public/@types/vtex.pixel-manager",
"vtex.render-runtime": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.126.1/public/@types/vtex.render-runtime",
"vtex.responsive-values": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.responsive-values@0.3.0/public/_types/react",
"vtex.pixel-manager": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.pixel-manager@1.9.0/public/@types/vtex.pixel-manager",
"vtex.render-runtime": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.135.1/public/@types/vtex.render-runtime",
"vtex.responsive-values": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.responsive-values@0.4.2/public/@types/vtex.responsive-values",
"vtex.store-icons": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-icons@0.18.0/public/@types/vtex.store-icons"
},
"version": "0.18.1"
}
}
Loading
Loading