Skip to content

Commit

Permalink
fix(messagelist): Ensure opened message row is visible in list
Browse files Browse the repository at this point in the history
Fixes: runbox#33
  • Loading branch information
castaway committed Jan 23, 2025
1 parent c1b3cb1 commit 3f6eebe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<single-mail-viewer #singlemailviewer
[messageActionsHandler]="messageActionsHandler"
[adjustableHeight]="false"
(afterLoadMessage)="updateMessageListHeight()"
(orientationChangeRequest)="mailViewerOrientationChangeRequest($event)"
(onClose)="singleMailViewerClosed($event)"></single-mail-viewer>
<div *ngIf="mailViewerOnRightSide && !singlemailviewer.messageId"
Expand Down Expand Up @@ -407,6 +408,7 @@ <h3 class="noMessageSelectedNotification">No Message Selected</h3>
[adjustableHeight]="true"
[showVerticalSplitButton]="allowMailViewerOrientationChange"
[messageActionsHandler]="messageActionsHandler"
(afterLoadMessage)="updateMessageListHeight()"
(orientationChangeRequest)="mailViewerOrientationChangeRequest($event)"
(onClose)="singleMailViewerClosed($event)"></single-mail-viewer>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,10 @@ export class AppComponent implements OnInit, AfterViewInit, CanvasTableSelectLis
this.updateUrlFragment();
}

updateMessageListHeight() {
this.canvastable.jumpToOpenMessage();
}

searchTextFieldFocus() {
if (!this.usewebsocketsearch && !this.dataReady) {
this.usewebsocketsearch = true;
Expand Down
15 changes: 10 additions & 5 deletions src/app/canvastable/canvastable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export class CanvasTableComponent implements AfterViewInit, DoCheck, OnInit {
columnResizeInProgress = false;
private scrollbarArea = false;

private jumpToMessage = false;

visibleColumnSeparatorAlpha = 0;
visibleColumnSeparatorIndex = 0;
lastClientY: number;
Expand Down Expand Up @@ -856,11 +858,7 @@ export class CanvasTableComponent implements AfterViewInit, DoCheck, OnInit {

// When loading a url with a fragment containing a msg id - scroll to there
public jumpToOpenMessage() {
// currently selected row in the centre:
if (this.rows.rowCount() > 0 && this.rows.openedRowIndex) {
this.topindex = this.rows.openedRowIndex - Math.round(this.maxVisibleRows / 2);
this.enforceScrollLimit();
}
this.jumpToMessage = true;
}

private enforceScrollLimit() {
Expand Down Expand Up @@ -971,6 +969,13 @@ export class CanvasTableComponent implements AfterViewInit, DoCheck, OnInit {
this.canv.height = this.wantedCanvasHeight;

this.maxVisibleRows = this.canv.scrollHeight / this.rowheight;
if(this.jumpToMessage) {
// currently selected row in the centre:
if (this.rows.rowCount() > 0 && this.rows.openedRowIndex) {
this.topindex = this.rows.openedRowIndex - Math.round(this.maxVisibleRows / 2);
}
this.jumpToMessage = false;
}
this.enforceScrollLimit();
this.hasChanges = true;
if (this.canv.clientWidth < this.autoRowWrapModeWidth) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/mailviewer/singlemailviewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class SingleMailViewerComponent implements OnInit, DoCheck, AfterViewInit
@Output() onClose: EventEmitter<string> = new EventEmitter();
@Output() afterViewInit: EventEmitter<any> = new EventEmitter();
@Output() orientationChangeRequest: EventEmitter<string> = new EventEmitter();
@Output() afterLoadMessage: EventEmitter<boolean> = new EventEmitter();

@Input() messageActionsHandler: MessageActions;
@Input() adjustableHeight: boolean;
Expand Down Expand Up @@ -777,6 +778,7 @@ export class SingleMailViewerComponent implements OnInit, DoCheck, AfterViewInit
this.resizer.resizePercentage(50);
}
}
this.afterLoadMessage.emit();
}, 0);
}

Expand Down

0 comments on commit 3f6eebe

Please sign in to comment.