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

fix: arrow position when placement is right again! #825

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/PickerInput/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
);

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

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

const [activeBarStyle, setActiveBarStyle] = React.useState<React.CSSProperties>({
position: 'absolute',
Expand All @@ -188,7 +189,6 @@ function RangeSelector<DateType extends object = any>(
width: offsetWidth,
[offsetUnit]: offsetLeft,
}));
const placementRight = placement?.toLowerCase().endsWith('right');
onActiveOffset(placementRight ? (parentWidth - offsetWidth - offsetLeft) : offsetLeft);
}
});
Expand Down
8 changes: 4 additions & 4 deletions 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-start: 0;"
style="position: absolute; width: 0px; inset-inline-end: 0;"
/>
</div>
</div>
Expand Down Expand Up @@ -184,7 +184,7 @@ exports[`Picker.Range panelRender 1`] = `
>
<div
class="rc-picker-range-arrow"
style="left: 0px;"
style="inset-inline-start: 0;"
/>
<div
class="rc-picker-panel-container rc-picker-date-panel-container"
Expand Down Expand Up @@ -250,7 +250,7 @@ exports[`Picker.Range use dateRender and monthCellRender in date range picker 1`
>
<div
class="rc-picker-range-arrow"
style="left: 0px;"
style="inset-inline-start: 0;"
/>
<div
class="rc-picker-panel-container rc-picker-date-panel-container"
Expand Down Expand Up @@ -1307,7 +1307,7 @@ exports[`Picker.Range use dateRender and monthCellRender in month range picker 1
>
<div
class="rc-picker-range-arrow"
style="left: 0px;"
style="inset-inline-start: 0;"
/>
<div
class="rc-picker-panel-container rc-picker-month-panel-container"
Expand Down
Loading