diff --git a/packages/@react-spectrum/s2/src/ColorArea.tsx b/packages/@react-spectrum/s2/src/ColorArea.tsx index 12548bef8ea..6c401b3efa8 100644 --- a/packages/@react-spectrum/s2/src/ColorArea.tsx +++ b/packages/@react-spectrum/s2/src/ColorArea.tsx @@ -13,7 +13,8 @@ import { ColorArea as AriaColorArea, ColorAreaProps as AriaColorAreaProps, - ContextValue + ContextValue, + useLocale } from 'react-aria-components'; import {ColorHandle} from './ColorHandle'; import {createContext, forwardRef} from 'react'; @@ -34,6 +35,7 @@ export const ColorArea = forwardRef(function ColorArea(props: ColorAreaProps, re [props, ref] = useSpectrumContextProps(props, ref, ColorAreaContext); let {UNSAFE_className = '', UNSAFE_style, styles} = props; let containerRef = useDOMRef(ref); + let {direction} = useLocale(); return ( ( state.getThumbPosition()} />) + getPosition={() => { + let {x, y} = state.getThumbPosition(); + return { + x: direction === 'ltr' ? x : 1 - x, + y + }; + }} />) } ); diff --git a/packages/@react-spectrum/s2/src/ColorSlider.tsx b/packages/@react-spectrum/s2/src/ColorSlider.tsx index 5fb7994722e..d9a78172a0e 100644 --- a/packages/@react-spectrum/s2/src/ColorSlider.tsx +++ b/packages/@react-spectrum/s2/src/ColorSlider.tsx @@ -41,7 +41,7 @@ export const ColorSlider = forwardRef(function ColorSlider(props: ColorSliderPro let {UNSAFE_className = '', UNSAFE_style, styles} = props; let containerRef = useDOMRef(ref); let trackRef = useRef(null); - let {locale} = useLocale(); + let {direction, locale} = useLocale(); return ( { - let x = state.orientation === 'horizontal' ? state.getThumbPercent(0) : 0.5; + let thumbLeft = direction === 'ltr' ? state.getThumbPercent(0) : 1 - state.getThumbPercent(0); + let x = state.orientation === 'horizontal' ? thumbLeft : 0.5; let y = state.orientation === 'horizontal' ? 0.5 : 1 - state.getThumbPercent(0); return {x, y}; }} />