Skip to content

Commit

Permalink
fix: arrow position when placement is right again!! (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Jun 12, 2024
1 parent 77ac25b commit 44a4a47
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion docs/examples/range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default () => {
value,
onChange,
onCalendarChange,
placement: 'topRight',
};

const rangePickerRef = React.useRef<PickerRef>(null);
Expand Down
5 changes: 3 additions & 2 deletions src/PickerInput/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
);

if (range) {
const placementRight = placement?.toLowerCase().endsWith('right') || rtl;
const placementRight = placement?.toLowerCase().endsWith('right');
const offsetUnit = placementRight ? 'insetInlineEnd' : 'insetInlineStart';
renderNode = (
<div
ref={wrapperRef}
Expand All @@ -217,7 +218,7 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
<div
ref={arrowRef}
className={`${prefixCls}-range-arrow`}
style={{ [placementRight ? 'insetInlineEnd' : 'insetInlineStart']: activeOffset }}
style={{ [offsetUnit]: activeOffset }}
/>

{/* Watch for container size */}
Expand Down
4 changes: 2 additions & 2 deletions src/PickerInput/Selector/RangeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ function RangeSelector<DateType extends object = any>(
});

// ====================== ActiveBar =======================
const placementRight = placement?.toLowerCase().endsWith('right') || rtl;
const offsetUnit = placementRight ? 'insetInlineEnd' : 'insetInlineStart';
const placementRight = placement?.toLowerCase().endsWith('right');
const offsetUnit = rtl ? 'insetInlineEnd' : 'insetInlineStart';

const [activeBarStyle, setActiveBarStyle] = React.useState<React.CSSProperties>({
position: 'absolute',
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/range.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ exports[`Picker.Range onPanelChange is array args should render correctly in pla
</div>
<div
class="rc-picker-active-bar"
style="position: absolute; width: 0px; inset-inline-end: 0;"
style="position: absolute; width: 0px; inset-inline-start: 0;"
/>
</div>
</div>
Expand Down

0 comments on commit 44a4a47

Please sign in to comment.