mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Rotate rows to ensure an item will be read in nav mode when scrolling
This commit is contained in:
@@ -187,14 +187,24 @@ export class AccessibilityManager implements IDisposable {
|
||||
|
||||
private _renderRows(start: number, end: number): void {
|
||||
const buffer: IBuffer = (<any>this._terminal.buffer);
|
||||
const setSize = (buffer.lines.length).toString();
|
||||
for (let i = start; i <= end; i++) {
|
||||
const lineData = buffer.translateBufferLineToString(buffer.ydisp + i, true);
|
||||
this._rowElements[i].textContent = lineData;
|
||||
this._rowElements[i].setAttribute('aria-posinset', (buffer.ydisp + i + 1).toString());
|
||||
this._rowElements[i].setAttribute('aria-setsize', (buffer.lines.length).toString());
|
||||
const posInSet = (buffer.ydisp + i + 1).toString();
|
||||
this._rowElements[i].setAttribute('aria-posinset', posInSet);
|
||||
this._rowElements[i].setAttribute('aria-setsize', setSize);
|
||||
}
|
||||
}
|
||||
|
||||
public rotateRows(): void {
|
||||
this._rowContainer.removeChild(this._rowElements.shift());
|
||||
const newRowIndex = this._rowElements.length;
|
||||
this._rowElements[newRowIndex] = this._createAccessibilityTreeNode();
|
||||
this._rowContainer.appendChild(this._rowElements[newRowIndex]);
|
||||
this._refreshRowsDimensions();
|
||||
}
|
||||
|
||||
private _refreshRowsDimensions(): void {
|
||||
const buffer: IBuffer = (<any>this._terminal.buffer);
|
||||
const dimensions = this._terminal.renderer.dimensions;
|
||||
@@ -342,6 +352,11 @@ class NavigationMode implements IDisposable {
|
||||
}
|
||||
|
||||
private _navigateToElement(absoluteRow: number): void {
|
||||
if (absoluteRow < this._terminal.buffer.ydisp || absoluteRow >= this._terminal.buffer.ydisp + this._terminal.rows) {
|
||||
// Rotate rows to ensure the next focused item is read out correctly
|
||||
this._accessibilityManager.rotateRows();
|
||||
}
|
||||
|
||||
absoluteRow = this._terminal.scrollToRow(absoluteRow);
|
||||
|
||||
if (this._focusedElement) {
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ export interface IEventEmitter {
|
||||
export interface IListenerType {
|
||||
(data?: any): void;
|
||||
listener?: (data?: any) => void;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ILinkMatcherOptions {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user