Skip to content

Commit

Permalink
fix(tabs): include button widths for comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
krisantrobus committed Nov 8, 2024
1 parent cfe4d21 commit 6e5e954
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/paste-core/components/code-block/src/utlis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export const useElementsOutOfBounds = (): {
* Compares the left side of the tab with the left side of the scrollable container position
* as the x value will not be 0 due to being offset in the screen.
*/
if (x < currentScrollContainerXOffset) {
if (Math.round(x) < Math.round(currentScrollContainerXOffset - 28)) {
leftOutOfBounds = tab;
}
/**
* Compares the right side to the end of container. Also ensure there are
* Compares the right side to the end of container and button width. Also ensure there are
* no value set as it loops through the array we don't want it to override the first value out of bounds.
*/
if (Math.round(right) > Math.round(currentScrollContainerRightPosition + 1) && !rightOutOfBounds) {
if (Math.round(right) > Math.round(currentScrollContainerRightPosition + 28) && !rightOutOfBounds) {
rightOutOfBounds = tab;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export const useElementsOutOfBounds = (): {
* Compares the left side of the tab with the left side of the scrollable container position
* as the x value will not be 0 due to being offset in the screen.
*/
if (x < currentScrollContainerXOffset) {
if (Math.round(x) < Math.round(currentScrollContainerXOffset - 28)) {
leftOutOfBounds = tab;
}
/**
* Compares the right side to the end of container. Also ensure there are
* Compares the right side to the end of container and button width. Also ensure there are
* no value set as it loops through the array we don't want it to override the first value out of bounds.
*/
if (Math.round(right) > Math.round(currentScrollContainerRightPosition + 1) && !rightOutOfBounds) {
if (Math.round(right) > Math.round(currentScrollContainerRightPosition + 28) && !rightOutOfBounds) {
rightOutOfBounds = tab;
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/paste-core/components/tabs/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export const useElementsOutOfBounds = (): {
* Compares the left side of the tab with the left side of the scrollable container position
* as the x value will not be 0 due to being offset in the screen.
*/
if (x < currentScrollContainerXOffset) {
if (Math.round(x) < Math.round(currentScrollContainerXOffset - 28)) {
leftOutOfBounds = tab;
}
/**
* Compares the right side to the end of container. Also ensure there are
* Compares the right side to the end of container and button width. Also ensure there are
* no value set as it loops through the array we don't want it to override the first value out of bounds.
*/
if (Math.round(right) > Math.round(currentScrollContainerRightPosition + 1) && !rightOutOfBounds) {
if (Math.round(right) > Math.round(currentScrollContainerRightPosition + 28) && !rightOutOfBounds) {
rightOutOfBounds = tab;
}
}
Expand Down

0 comments on commit 6e5e954

Please sign in to comment.