Skip to content

Commit

Permalink
fix(core): Fix dont parse accessiblity props or ID if already passing…
Browse files Browse the repository at this point in the history
… to RNW
  • Loading branch information
natew committed Oct 30, 2022
1 parent 05bedff commit 2797532
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 60 deletions.
9 changes: 6 additions & 3 deletions apps/sandbox/Sandbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '../site/app.css'

// import { AppRegistry, useColorScheme } from 'react-native'
import { TamaguiProvider, styled } from '@tamagui/core'
import { SheetDemo } from '@tamagui/demos'
import { LabelDemo, SheetDemo } from '@tamagui/demos'
// import { SliderDemo, SwitchDemo } from '@tamagui/demos'
import { AnimationsDemo, AnimationsPresenceDemo } from '@tamagui/demos'
// import { SliderDemo, SwitchDemo } from '@tamagui/demos'
Expand Down Expand Up @@ -99,11 +99,14 @@ export const Sandbox = () => {

{/* <SheetDemo /> */}

<YStack space="$2" $gtMd={{ space: '$10' }}>
{/* space */}
{/* <YStack space="$2" $gtMd={{ space: '$10' }}>
<Circle bc="red" size="$10" />
<Circle bc="red" size="$10" />
<Circle bc="red" size="$10" />
</YStack>
</YStack> */}

<LabelDemo />

{/* <Square size={100} bc="red" /> */}
{/* <SheetDemo /> */}
Expand Down
1 change: 0 additions & 1 deletion next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

- When you focus an input in a dialog on mobile or a propover etc. then it disappears
- select had a perf regression
- label htmlFor broke
- site design system docs (for use in cli later)
- blog post / home: lighthouse score diff between compiler on / off
- runthrough and check:
Expand Down
120 changes: 66 additions & 54 deletions packages/core/src/helpers/getSplitStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,70 +257,81 @@ export const getSplitStyles: StyleSplitter = (
continue
}

if (accessibilityDirectMap[keyInit]) {
viewProps[accessibilityDirectMap[keyInit]] = valInit
if (keyInit === 'id' || keyInit === 'nativeID') {
usedKeys[keyInit] = 1
if (staticConfig.isReactNative) {
viewProps.nativeID = valInit
} else {
viewProps.id = valInit
}
continue
}

let didUseKeyInit = true
switch (keyInit) {
case 'nativeID': {
viewProps.id = valInit
break

if (staticConfig.isReactNative) {
didUseKeyInit = false
} else {
if (accessibilityDirectMap[keyInit]) {
viewProps[accessibilityDirectMap[keyInit]] = valInit
usedKeys[keyInit] = 1
continue
}
case 'accessibilityRole': {
if (valInit === 'none') {
viewProps.role = 'presentation'
} else {
viewProps.role = accessibilityRoleToWebRole[valInit] || valInit

switch (keyInit) {
case 'accessibilityRole': {
if (valInit === 'none') {
viewProps.role = 'presentation'
} else {
viewProps.role = accessibilityRoleToWebRole[valInit] || valInit
}
break
}
break
}
case 'accessibilityControls': {
viewProps['aria-controls'] = processIDRefList(valInit)
break
}
case 'accessibilityDescribedBy': {
viewProps['aria-describedby'] = processIDRefList(valInit)
break
}
case 'accessibilityFlowTo': {
viewProps['aria-flowto'] = processIDRefList(valInit)
break
}
case 'accessibilityLabelledBy': {
viewProps['aria-labelledby'] = processIDRefList(valInit)
break
}
case 'accessibilityKeyShortcuts': {
if (Array.isArray(valInit)) {
viewProps['aria-keyshortcuts'] = valInit.join(' ')
case 'accessibilityControls': {
viewProps['aria-controls'] = processIDRefList(valInit)
break
}
break
}
case 'accessibilityLiveRegion': {
viewProps['aria-live'] = valInit === 'none' ? 'off' : valInit
break
}
case 'accessibilityReadOnly': {
viewProps['aria-readonly'] = valInit
// Enhance with native semantics
if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {
viewProps.readOnly = true
case 'accessibilityDescribedBy': {
viewProps['aria-describedby'] = processIDRefList(valInit)
break
}
break
}
case 'accessibilityRequired': {
viewProps['aria-required'] = valInit
// Enhance with native semantics
if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {
viewProps.required = true
case 'accessibilityFlowTo': {
viewProps['aria-flowto'] = processIDRefList(valInit)
break
}
case 'accessibilityLabelledBy': {
viewProps['aria-labelledby'] = processIDRefList(valInit)
break
}
case 'accessibilityKeyShortcuts': {
if (Array.isArray(valInit)) {
viewProps['aria-keyshortcuts'] = valInit.join(' ')
}
break
}
case 'accessibilityLiveRegion': {
viewProps['aria-live'] = valInit === 'none' ? 'off' : valInit
break
}
case 'accessibilityReadOnly': {
viewProps['aria-readonly'] = valInit
// Enhance with native semantics
if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {
viewProps.readOnly = true
}
break
}
case 'accessibilityRequired': {
viewProps['aria-required'] = valInit
// Enhance with native semantics
if (elementType === 'input' || elementType === 'select' || elementType === 'textarea') {
viewProps.required = true
}
break
}
default: {
didUseKeyInit = false
}
break
}
default: {
didUseKeyInit = false
}
}

Expand Down Expand Up @@ -615,6 +626,7 @@ export const getSplitStyles: StyleSplitter = (
}
if (!shouldDoClasses) {
for (const key in parentSplitStyles.style) {
if (key in classNames) continue
if (key in style) continue
style[key] = parentSplitStyles.style[key]
}
Expand Down
1 change: 0 additions & 1 deletion packages/demos/src/LabelDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { Input, Label, Switch, XStack, YStack } from 'tamagui'

export function LabelDemo() {
Expand Down
10 changes: 9 additions & 1 deletion packages/label/src/Label.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { useComposedRefs } from '@tamagui/compose-refs'
import { GetProps, ReactComponentWithRef, isWeb, styled, themeable, useId } from '@tamagui/core'
import {
GetProps,
ReactComponentWithRef,
isWeb,
styled,
themeable,
useId,
useIsomorphicLayoutEffect,
} from '@tamagui/core'
import { createContext } from '@tamagui/create-context'
import { focusFocusable } from '@tamagui/focusable'
import { getButtonSized } from '@tamagui/get-button-sized'
Expand Down

1 comment on commit 2797532

@vercel
Copy link

@vercel vercel bot commented on 2797532 Oct 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

site – ./

site-git-master-tamagui.vercel.app
site-tamagui.vercel.app
site-beta-beige.vercel.app

Please sign in to comment.