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(AnalyticalTable): support RTL #466

Merged
merged 3 commits into from
Apr 29, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface ColumnHeaderProps {
className: string;
column: ColumnType;
style: CSSProperties;
isLastColumn?: boolean;
onSort?: (e: CustomEvent<{ column: unknown; sortDirection: string }>) => void;
onGroupBy?: (e: CustomEvent<{ column: unknown; isGrouped: boolean }>) => void;
onDragStart: DragEventHandler<HTMLDivElement>;
Expand Down Expand Up @@ -102,7 +101,6 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props: ColumnHeaderProps) =>
column,
className,
style,
isLastColumn,
onSort,
onGroupBy,
onDragEnter,
Expand All @@ -122,13 +120,12 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props: ColumnHeaderProps) =>
const filterIcon = isFiltered ? <Icon name="filter" /> : null;
const groupingIcon = column.isGrouped ? <Icon name="group-2" /> : null;

const isResizable = !isLastColumn && column.canResize;
const hasPopover = column.canGroupBy || column.canSort || column.canFilter;
const innerStyle: CSSProperties = useMemo(() => {
const modifiedStyles: CSSProperties = {
cursor: hasPopover ? 'pointer' : 'auto'
};
if (isResizable) {
if (column.canResize) {
modifiedStyles.maxWidth = `calc(100% - 16px)`;
}
if (dragOver) {
Expand All @@ -140,12 +137,9 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props: ColumnHeaderProps) =>
if (column.hAlign === TextAlign.End) {
modifiedStyles.justifyContent = 'flex-end';
modifiedStyles.maxWidth = '';
if (isLastColumn) {
modifiedStyles.paddingRight = `calc(${ThemingParameters.sapScrollBar_Dimension} + 1rem)`;
}
}
return modifiedStyles;
}, [isResizable, dragOver, hasPopover]);
}, [column.canResize, dragOver, hasPopover]);

const popoverRef = useRef<Ui5PopoverDomRef>(null);

Expand Down Expand Up @@ -188,8 +182,8 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props: ColumnHeaderProps) =>
</div>
</div>
{hasPopover && <ColumnHeaderModal column={column} onSort={onSort} onGroupBy={onGroupBy} ref={popoverRef} />}
{column.getResizerProps && (
<div {...column.getResizerProps()} className={`${classes.resizer} ${isLastColumn ? classes.lastColumn : ''}`} />
{column.canResize && column.getResizerProps && (
<div {...column.getResizerProps()} className={`${classes.resizer}`} />
)}
</div>
);
Expand Down
Loading