Skip to content

Commit

Permalink
fix: Prevent dropdown misplacement in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jperals committed Jan 16, 2025
1 parent deb8ce1 commit f59383b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/internal/components/dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@ const Dropdown = ({
target.style.insetInlineStart = position.insetInlineStart;
}

const targetRect = getLogicalBoundingClientRect(target);

// Position normal overflow dropdowns with fixed positioning relative to viewport
if (expandToViewport && !interior) {
target.style.position = 'fixed';
if (position.dropBlockStart) {
target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;
target.style.insetBlockStart = `${triggerBox.top - targetRect.blockSize}px`;

Check warning on line 240 in src/internal/components/dropdown/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/internal/components/dropdown/index.tsx#L240

Added line #L240 was not covered by tests
} else {
target.style.insetBlockStart = `${triggerBox.bottom}px`;
}
Expand Down Expand Up @@ -393,9 +395,10 @@ const Dropdown = ({
if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {
const triggerRect = getLogicalBoundingClientRect(triggerRef.current);
const target = dropdownRef.current;
const targetRect = getLogicalBoundingClientRect(target);
if (fixedPosition.current) {
if (fixedPosition.current.dropBlockStart) {
dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;
target.style.insetBlockStart = `${triggerRect.insetBlockStart - targetRect.blockSize}px`;

Check warning on line 401 in src/internal/components/dropdown/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/internal/components/dropdown/index.tsx#L401

Added line #L401 was not covered by tests
} else {
target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;
}
Expand Down

0 comments on commit f59383b

Please sign in to comment.