Skip to content

Commit

Permalink
[widget] disable scroll bar focus
Browse files Browse the repository at this point in the history
widgets should handle key up and down to change scrolling programmatically

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Aug 2, 2019
1 parent a851786 commit f078d85
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/browser/widgets/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class BaseWidget extends Widget {
const container = await this.getScrollContainer();
container.style.overflow = 'hidden';
this.scrollBar = new PerfectScrollbar(container, this.scrollOptions);
this.disableScrollBarFocus(container);
this.toDisposeOnDetach.push(addEventListener(container, <any>'ps-y-reach-end', () => { this.onScrollYReachEndEmitter.fire(undefined); }));
this.toDisposeOnDetach.push(addEventListener(container, <any>'ps-scroll-up', () => { this.onScrollUpEmitter.fire(undefined); }));
this.toDisposeOnDetach.push(Disposable.create(() => {
Expand All @@ -109,6 +110,17 @@ export class BaseWidget extends Widget {
return this.node;
}

protected disableScrollBarFocus(scrollContainer: HTMLElement): void {
for (const thumbs of [scrollContainer.getElementsByClassName('ps__thumb-x'), scrollContainer.getElementsByClassName('ps__thumb-y')]) {
for (let i = 0; i < thumbs.length; i++) {
const element = thumbs.item(i);
if (element) {
element.removeAttribute('tabIndex');
}
}
}
}

protected onUpdateRequest(msg: Message): void {
super.onUpdateRequest(msg);
if (this.scrollBar) {
Expand Down

0 comments on commit f078d85

Please sign in to comment.