Skip to content

Commit

Permalink
fix: table: updates scrollable div by removing deprecated css property (
Browse files Browse the repository at this point in the history
#655)

* fix: table: updates scrollable div by removing deprecated css property

* chore: table: update snaps

* chore: table: update border to hide in mozilla browsers

* chore: table: updates snaps and sticky unit test
  • Loading branch information
dkilgore-eightfold authored Jun 27, 2023
1 parent 0c00967 commit ee4c5d6
Show file tree
Hide file tree
Showing 23 changed files with 376 additions and 445 deletions.
85 changes: 11 additions & 74 deletions src/components/DateTimePicker/DatePicker/Styles/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ $picker-input-padding-vertical: max(

&::-webkit-scrollbar {
background-color: transparent;
height: 16px;
width: 16px;
height: $space-m;
width: $space-m;
}

&::-webkit-scrollbar-button {
display: none;
}

&::-webkit-scrollbar-corner {
Expand All @@ -71,85 +75,18 @@ $picker-input-padding-vertical: max(

&::-webkit-scrollbar-thumb {
background-color: transparent;
border: 5px solid transparent;
border-radius: $border-radius-xl;
box-shadow: 4px 0px 0px 4px rgba(105, 113, 127, 0.7) inset;
}

&::-webkit-scrollbar-track {
-webkit-box-shadow: none;
background-color: transparent;
}

@supports (overflow: overlay) {
overflow: overlay;

&:focus-within,
&:focus-visible,
&:hover,
&:hover:focus {
&::-webkit-scrollbar {
display: block;
height: 16px;
width: 16px;
}

&::-webkit-scrollbar-button {
display: none;
}

&::-webkit-scrollbar-corner {
background-color: transparent;
}

&::-webkit-scrollbar-track {
background-color: transparent;
}

&::-webkit-scrollbar-track-piece {
background-color: transparent;
}

&::-webkit-scrollbar-thumb {
background-color: transparent;
border: 5px solid transparent;
border-radius: 24px;
box-shadow: 4px 0px 0px 4px rgba(105, 113, 127, 0.7) inset;
}
}
}

@supports not (overflow: overlay) {
overflow: auto;

&:focus-within,
&:focus-visible,
&:hover,
&:hover:focus {
-ms-overflow-style: none;
scrollbar-width: thin;

&::-webkit-scrollbar {
background-color: var(--picker-background-color);
height: 16px;
width: 16px;
}

&::-webkit-scrollbar-corner {
background-color: var(--picker-background-color);
border: 1px solid var(--picker-background-color);
border-bottom-right-radius: $picker-partial-border-radius;
}

&::-webkit-scrollbar-thumb {
background-color: transparent;
border: 5px solid transparent;
border-radius: 24px;
box-shadow: 4px 0px 0px 4px rgba(105, 113, 127, 0.7) inset;
}

&::-webkit-scrollbar-track {
-webkit-box-shadow: none;
background-color: var(--picker-background-color);
}
}
&::-webkit-scrollbar-track-piece {
background-color: transparent;
}
}

Expand Down
31 changes: 20 additions & 11 deletions src/components/Table/Internal/Body/Scroller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import React, {
import { ButtonShape, ButtonSize, SecondaryButton } from '../../../Button';
import { IconName } from '../../../Icon';
import { ColumnType } from '../../Table.types';
import { ScrollerProps, ScrollerRef } from '../OcTable.types';
import {
ScrollerProps,
ScrollerRef,
VERTICAL_SCROLL_OFFSET,
} from '../OcTable.types';

import styles from '../octable.module.scss';

Expand All @@ -24,9 +28,10 @@ export const Scroller = React.forwardRef(
scrollBodyRef,
stickyOffsets,
scrollHeaderRef,
titleRef,
scrollLeftAriaLabelText,
scrollRightAriaLabelText,
titleRef,
verticalScroll = false,
}: ScrollerProps<RecordType>,
ref: ForwardedRef<ScrollerRef>
) => {
Expand Down Expand Up @@ -82,12 +87,13 @@ export const Scroller = React.forwardRef(
const { height: stickyHeaderHeight = 0 } =
scrollHeaderRef?.current?.getBoundingClientRect?.() || {};
return (
rowTop -
scrollBodyTop +
stickyHeaderHeight +
rowHeight / 2 -
BUTTON_HEIGHT / 2 +
titleHeight
(rowTop -
scrollBodyTop +
stickyHeaderHeight +
rowHeight / 2 -
BUTTON_HEIGHT / 2 +
titleHeight) |
0
);
};

Expand Down Expand Up @@ -118,7 +124,7 @@ export const Scroller = React.forwardRef(
});
};

const noScroller = (): boolean => {
const noHorizontalScroller = (): boolean => {
return (
scrollBodyRef?.current?.clientWidth >=
scrollBodyRef?.current?.scrollWidth
Expand Down Expand Up @@ -163,7 +169,7 @@ export const Scroller = React.forwardRef(
};
}, []);

if (noScroller()) return null;
if (noHorizontalScroller()) return null;

return (
<>
Expand All @@ -185,7 +191,10 @@ export const Scroller = React.forwardRef(
<SecondaryButton
classNames={styles.scrollerButton}
style={{
right: rightButtonOffset + BUTTON_PADDING,
right:
rightButtonOffset +
(verticalScroll ? VERTICAL_SCROLL_OFFSET : 0) +
BUTTON_PADDING,
opacity: rightButtonVisible && visible ? 1 : 0,
top: getButtonTop(),
}}
Expand Down
5 changes: 5 additions & 0 deletions src/components/Table/Internal/Cell/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { forwardRef, memo, Ref, useContext, useMemo } from 'react';
import { mergeClasses } from '../../../../shared/utilities';
import shallowEqual from 'shallowequal';
import { VERTICAL_SCROLL_OFFSET } from '../OcTable.types';
import type {
RenderedCell,
CellType,
Expand Down Expand Up @@ -179,6 +180,10 @@ function Cell<RecordType extends DefaultRecordType>(
if (isFixRight) {
fixedStyle.position = 'sticky';
fixedStyle.right = fixRight as number;

if (fixRight <= VERTICAL_SCROLL_OFFSET) {
fixedStyle.borderRightColor = 'transparent';
}
}

// ====================== Align =======================
Expand Down
13 changes: 3 additions & 10 deletions src/components/Table/Internal/FixedHolder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import React, {
useMemo,
useRef,
} from 'react';
import {
fillRef,
isStyleSupport,
mergeClasses,
} from '../../../../shared/utilities';
import { fillRef, mergeClasses } from '../../../../shared/utilities';
import ColGroup from '../ColGroup';
import type { ColumnsType, ColumnType } from '../OcTable.types';
import { FixedHeaderProps } from './FixedHolder.types';
Expand Down Expand Up @@ -56,11 +52,8 @@ const FixedHolder = forwardRef<HTMLDivElement, FixedHeaderProps<unknown>>(
ref
) => {
const { scrollbarSize, isSticky } = useContext(TableContext);
const supportedScrollbarSize: number = isStyleSupport('scrollbar-gutter')
? 0
: scrollbarSize;
const combinationScrollBarSize: number =
isSticky && !fixHeader ? 0 : supportedScrollbarSize;
isSticky && !fixHeader ? 0 : scrollbarSize;
const scrollRef: React.MutableRefObject<HTMLDivElement> =
useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -90,7 +83,7 @@ const FixedHolder = forwardRef<HTMLDivElement, FixedHeaderProps<unknown>>(

// Check if all flattenColumns has width
const allFlattenColumnsWithWidth: boolean = useMemo(
() => flattenColumns.every((column) => column.width >= 0),
() => flattenColumns.every((column) => Number(column.width) >= 0),
[flattenColumns]
);

Expand Down
Loading

0 comments on commit ee4c5d6

Please sign in to comment.