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(dropdown): resolve sentry errors in positionElement #1883

Merged
merged 3 commits into from
May 6, 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
3 changes: 3 additions & 0 deletions packages/sage-react/lib/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export const Dropdown = ({
const button = el;
const panel = el.lastElementChild;

// if panel is null, return
if (!panel) return;

// Dimensions
const buttonDimensions = button.getBoundingClientRect();
const panelDimensions = panel.getBoundingClientRect();
Expand Down
9 changes: 6 additions & 3 deletions packages/sage-system/lib/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ Sage.dropdown = (function () {

let directionX = null;
let directionY = null;

// Elements
const button = dropdownElement;
const panel = dropdownElement.lastElementChild;
const win = panel.ownerDocument.defaultView;
const docEl = window.document.documentElement;

// if panel is null, return
if (!panel) return;

panel.style.top = ''; // resets the style
panel.style.left = ''; // resets the style
panel.style.right = ''; // resets the style
Expand Down Expand Up @@ -235,7 +238,7 @@ Sage.dropdown = (function () {
const enoughSpaceBelow = viewport.bottom > (offset.bottom + panelHeight);
const enoughSpaceLeft = viewport.left < (offset.left + panelWidth);
const enoughSpaceRight = viewport.right > (offset.right + panelWidth);

// Check if there is enough space to the top or bottom
if (!enoughSpaceBelow && enoughSpaceAbove) {
directionY = 'above';
Expand All @@ -248,7 +251,7 @@ Sage.dropdown = (function () {
} else if (directionY === 'below') {
// find test case
// panel.style.top = 0;
}
}

// Check if there is enough space to the left or right
if (!enoughSpaceRight && enoughSpaceLeft) {
Expand Down
Loading