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: Focusing filter controls scrolls to the field along with the corresponding grid (2024.1) #2419

Merged
merged 3 commits into from Jan 22, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,6 +21,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import { IScrolleeProps } from "./types";
import S from "./Scrollee.module.css";
import { action } from "mobx";

/*
Component translating its content according to scrollOffsetSource.
Expand All @@ -29,6 +30,25 @@ import S from "./Scrollee.module.css";
// TODO: Maybe add hideOverflow property to disable content clipping? (or allow some custom class?)
@observer
export default class Scrollee extends React.Component<IScrolleeProps> {

@action.bound
handleFocus(event: any) {
const tableElement = event.target.closest(this.props.controlScrollStateSelector);
const tableRect = tableElement?.getBoundingClientRect();
const targetRect = event.target.getBoundingClientRect();
const overLeft = Math.min(0, targetRect.left - tableRect.left);
const overRight = Math.max(0, targetRect.right - tableRect?.right);
if(overRight) {
this.props.scrollOffsetSource.scrollBy({
deltaLeft: overRight + (this.props.controlScrollStatePadding?.right || 0)
})
} else if(overLeft) {
this.props.scrollOffsetSource.scrollBy({
deltaLeft: overLeft - (this.props.controlScrollStatePadding?.left || 0)
})
}
}

public render() {
return (
<div
Expand All @@ -38,6 +58,7 @@ export default class Scrollee extends React.Component<IScrolleeProps> {
height: this.props.height,
zIndex: this.props.zIndex || 0,
}}
onFocus={this.props.controlScrollStateByFocus ? this.handleFocus : undefined}
>
<div
className={S.scrolleeShifted}
Expand Down
Expand Up @@ -34,6 +34,13 @@ export class SimpleScrollState implements IScrollState {
}
}

scrollBy(coords: {deltaLeft?: number; deltaTop?: number}) {
this.scrollTo({
scrollLeft: coords.deltaLeft !== undefined ? this.scrollLeft + coords.deltaLeft : undefined,
scrollTop: coords.deltaTop !== undefined ? this.scrollTop + coords.deltaTop : undefined
})
}

@observable scrollTop = 0;
@observable scrollLeft = 0;

Expand Down
Expand Up @@ -32,7 +32,7 @@ along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
overflow: clip;
}

.loadingOverlay {
Expand Down
Expand Up @@ -434,7 +434,7 @@ export class RawTable extends React.Component<ITableProps & { isVisible: boolean
: undefined;

return (
<div className={S.table}>
<div className={`${S.table} tableContainer`}>
{this.props.isLoading && (
<div className={S.loadingOverlay}>
<div className={S.loadingIcon}>
Expand Down Expand Up @@ -468,6 +468,9 @@ export class RawTable extends React.Component<ITableProps & { isVisible: boolean
fixedVert={true}
zIndex={100}
width={contentRect.bounds!.width - 10 - this.fixedColumnsWidth}
controlScrollStateByFocus={true}
controlScrollStateSelector=".tableContainer"
controlScrollStatePadding={{ left: 40, right: 40 }}
>
<DragDropContext onDragEnd={(result) => this.onColumnDragEnd(result)}>
<Droppable droppableId="headers" direction="horizontal" >
Expand Down
Expand Up @@ -91,6 +91,8 @@ export interface IScrollState extends IScrollOffsetSource, IScrollOffsetTarget {
scrollToFunction: ((coords: { scrollLeft?: number; scrollTop?: number }) => void) | undefined;

scrollTo(coords: { scrollLeft?: number; scrollTop?: number }): void;

scrollBy(coords: {deltaLeft?: number; deltaTop?: number}): void;
}

export interface IScrollOffsetSource {
Expand Down Expand Up @@ -184,9 +186,15 @@ export interface IScrolleeProps {
fixedHoriz?: boolean;
fixedVert?: boolean;
zIndex?: number | undefined;
scrollOffsetSource: IScrollOffsetSource;
scrollOffsetSource: IScrollState;
offsetLeft?: number;
offsetTop?: number;
controlScrollStateByFocus?: boolean;
controlScrollStateSelector?: string;
controlScrollStatePadding?: {
left: number,
right: number,
}
}

export interface IHeaderRowProps {
Expand Down
2 changes: 2 additions & 0 deletions test/docker-compose.yml
Expand Up @@ -36,6 +36,8 @@ services:
- ExternalDomain_SetOnStart=${ExternalDomain_SetOnStart}
- OrigamSettings_ReportDefinitionsPath=${OrigamSettings_ReportDefinitionsPath}
- EnableChat=${EnableChat}
- BUILDKIT_PROGRESS=tty
- CI=true
ports:
- "8080:8080"
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion test/tests_e2e/testTools.js
Expand Up @@ -46,7 +46,7 @@ async function beforeEachTest(){
// slowMo: 50,
headless: false,
defaultViewport: {
width: 1024,
width: 1800,
height: 2000, // to make all 30 lines visible and avoid the need for scrolling
},
args: [
Expand Down