Fix clickable being announced for all modelview text (#8384)

* Fix clickable being announced for all modelview text

* Remove unused method

* Move API changes into proposed
This commit is contained in:
Charles Gagnon
2019-11-22 11:01:46 -08:00
committed by GitHub
parent fc0c05c755
commit 52de2b4751
7 changed files with 45 additions and 32 deletions

View File

@@ -10,12 +10,12 @@ import {
import * as azdata from 'azdata';
import { IComponent, IComponentDescriptor, IModelStore } from 'sql/workbench/browser/modelComponents/interfaces';
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/workbench/browser/modelComponents/interfaces';
import { TitledComponent } from 'sql/workbench/browser/modelComponents/titledComponent';
@Component({
selector: 'modelview-hyperlink',
template: `<a [href]="getUrl()" [title]="title" target="blank">{{getLabel()}}</a>`
template: `<a [href]="getUrl()" [title]="title" target="blank" (click)="onClick()">{{getLabel()}}</a>`
})
export default class HyperlinkComponent extends TitledComponent implements IComponent, OnDestroy, AfterViewInit {
@Input() descriptor: IComponentDescriptor;
@@ -65,4 +65,14 @@ export default class HyperlinkComponent extends TitledComponent implements IComp
public getUrl(): string {
return this.url;
}
public onClick(): boolean {
this.fireEvent({
eventType: ComponentEventType.onDidClick,
args: undefined
});
// If we don't have a URL then return false since that just defaults to the URL for the workbench. We assume
// if a blank url is specified then the caller is handling the click themselves.
return !!this.url;
}
}

View File

@@ -11,7 +11,7 @@ import {
import * as azdata from 'azdata';
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/workbench/browser/modelComponents/interfaces';
import { IComponent, IComponentDescriptor, IModelStore } from 'sql/workbench/browser/modelComponents/interfaces';
import { SafeHtml, DomSanitizer } from '@angular/platform-browser';
import { TitledComponent } from 'sql/workbench/browser/modelComponents/titledComponent';
@@ -19,14 +19,14 @@ import { TitledComponent } from 'sql/workbench/browser/modelComponents/titledCom
selector: 'modelview-text',
template: `
<div *ngIf="showDiv;else noDiv" style="display:flex;flex-flow:row;align-items:center;" [style.width]="getWidth()" [style.height]="getHeight()">
<p [innerHTML]="getValue()" [title]="title" [ngStyle]="this.CSSStyles" (click)="onClick()"></p>
<p [innerHTML]="getValue()" [title]="title" [ngStyle]="this.CSSStyles" [attr.role]="ariaRole"></p>
<p *ngIf="requiredIndicator" style="color:red;margin-left:5px;">*</p>
<div *ngIf="description" tabindex="0" class="modelview-text-tooltip" [attr.aria-label]="description">
<div class="modelview-text-tooltip-content" [innerHTML]="description"></div>
</div>
</div>
<ng-template #noDiv>
<p [innerHTML]="getValue()" [style.display]="display" [style.width]="getWidth()" [style.height]="getHeight()" [title]="title" [attr.role]="ariaRole" [ngStyle]="this.CSSStyles" (click)="onClick()"></p>
<p [innerHTML]="getValue()" [style.display]="display" [style.width]="getWidth()" [style.height]="getHeight()" [title]="title" [attr.role]="ariaRole" [ngStyle]="this.CSSStyles"></p>
</ng-template>`
})
export default class TextComponent extends TitledComponent implements IComponent, OnDestroy, AfterViewInit {
@@ -98,11 +98,4 @@ export default class TextComponent extends TitledComponent implements IComponent
public get showDiv(): boolean {
return this.requiredIndicator || !!this.description;
}
public onClick() {
this.fireEvent({
eventType: ComponentEventType.onDidClick,
args: undefined
});
}
}