Skip to content

Commit

Permalink
fix: drop target highlighting is moved when the Settings bar is open
Browse files Browse the repository at this point in the history
  • Loading branch information
raaymax committed Mar 6, 2024
1 parent 72a2f75 commit 3fdecfb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ui/src/builder/BuilderApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<BuilderInstanceTracker
:key="candidateInstancePath"
class="insertionOverlayTracker"
:ignore-settings-sidebar="true"
:is-off-bounds-allowed="true"
:instance-path="candidateInstancePath"
:match-size="true"
Expand All @@ -99,6 +100,7 @@
<BuilderInstanceTracker
:key="candidateInstancePath"
class="insertionLabelTracker"
:ignore-settings-sidebar="true"
:instance-path="candidateInstancePath"
:vertical-offset-pixels="-48"
>
Expand Down
22 changes: 14 additions & 8 deletions ui/src/builder/BuilderInstanceTracker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface Props {
matchSize?: boolean;
verticalOffsetPixels?: number;
isOffBoundsAllowed?: boolean;
ignoreSettingsSidebar?: boolean;
}
const props = defineProps<Props>();
const { instancePath, matchSize, verticalOffsetPixels, isOffBoundsAllowed } =
Expand All @@ -37,7 +38,10 @@ const trackElement = (el: HTMLElement) => {
const { clientWidth: rendererWidth } = rendererEl;
const { left: rendererX } = rendererEl.getBoundingClientRect();
const settingsEl = document.querySelector(".BuilderSettings");
const hiderTabEl = document.querySelector(".settingsHiderTab");
const hiderWidth = hiderTabEl?.clientWidth || 0;
const { clientWidth: settingsWidth } = settingsEl || { clientWidth: 0 };
const fullSettingsWidth = settingsWidth + hiderWidth;
const { left: settingsLeft } = settingsEl?.getBoundingClientRect() || {
left: Infinity,
};
Expand All @@ -60,15 +64,17 @@ const trackElement = (el: HTMLElement) => {
trackerY = Math.min(bodyHeight - contentsHeight, trackerY); // Bottom boundary
}
let correction = 0;
if (settingsLeft < rendererX + rendererWidth) {
const trackerEnd = trackerX + contentsWidth;
const rendererEnd = rendererX + rendererWidth;
const distanceToRight = Math.max(rendererEnd - trackerEnd, 0);
correction = Math.max(settingsWidth - distanceToRight, 0);
}
if (!props.ignoreSettingsSidebar) {
let correction = 0;
if (settingsLeft < rendererX + rendererWidth) {
const trackerEnd = trackerX + contentsWidth;
const rendererEnd = rendererX + rendererWidth;
const distanceToRight = Math.max(rendererEnd - trackerEnd, 0);
correction = Math.max(fullSettingsWidth - distanceToRight, 0);
}
trackerX -= correction;
trackerX -= correction;
}
rootStyle.value = {
top: `${trackerY}px`,
Expand Down

0 comments on commit 3fdecfb

Please sign in to comment.