@@ -8,6 +8,7 @@ import useInputProps from './hooks/useInputProps';
8
8
import useRootProps from './hooks/useRootProps' ;
9
9
import Icon , { ClearIcon } from './Icon' ;
10
10
import Input , { type InputRef } from './Input' ;
11
+ import { getoffsetUnit , getRealPlacement } from '../../utils/uiUtil' ;
11
12
12
13
export type SelectorIdType =
13
14
| string
@@ -170,26 +171,26 @@ function RangeSelector<DateType extends object = any>(
170
171
} ) ;
171
172
172
173
// ====================== ActiveBar =======================
173
- const placementRight = placement ?. toLowerCase ( ) . endsWith ( 'right' ) ;
174
- const offsetUnit = rtl ? 'insetInlineEnd' : 'insetInlineStart' ;
175
-
174
+ const realPlacement = getRealPlacement ( placement , rtl ) ;
175
+ const offsetUnit = getoffsetUnit ( realPlacement , rtl ) ;
176
+ const placementRight = realPlacement ?. toLowerCase ( ) . endsWith ( 'right' ) ;
176
177
const [ activeBarStyle , setActiveBarStyle ] = React . useState < React . CSSProperties > ( {
177
178
position : 'absolute' ,
178
179
width : 0 ,
179
- [ offsetUnit ] : 0 ,
180
180
} ) ;
181
181
182
182
const syncActiveOffset = useEvent ( ( ) => {
183
183
const input = getInput ( activeIndex ) ;
184
184
if ( input ) {
185
185
const { offsetWidth, offsetLeft, offsetParent } = input . nativeElement ;
186
186
const parentWidth = ( offsetParent as HTMLElement ) ?. offsetWidth || 0 ;
187
+ const activeOffset = placementRight ? ( parentWidth - offsetWidth - offsetLeft ) : offsetLeft ;
187
188
setActiveBarStyle ( ( ori ) => ( {
188
189
...ori ,
189
190
width : offsetWidth ,
190
- [ offsetUnit ] : offsetLeft ,
191
+ [ offsetUnit ] : activeOffset ,
191
192
} ) ) ;
192
- onActiveOffset ( placementRight ? ( parentWidth - offsetWidth - offsetLeft ) : offsetLeft ) ;
193
+ onActiveOffset ( activeOffset ) ;
193
194
}
194
195
} ) ;
195
196
0 commit comments