Skip to content

Commit

Permalink
feat(Field): adding data-auto-ids to the new novo-field elements (#1349)
Browse files Browse the repository at this point in the history
* feat(Field): trying out a way to add data-auto-ids to the new novo-field elements

* adding/changing field auto ids

* using label instead of value
  • Loading branch information
dvoegelin committed Nov 4, 2022
1 parent 1504e0f commit 4cb454b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions projects/novo-elements/src/elements/field/field-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export abstract class NovoFieldControl<T> {

/** The last key pressed. */
lastKeyValue: string | null;

/** The last cursor position. */
lastCaretPosition: number | null;

Expand Down
5 changes: 4 additions & 1 deletion projects/novo-elements/src/elements/field/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export class NovoFieldElement implements AfterContentInit, OnDestroy {
this._validateControlChild();

const control = this._control;

if (control.controlType) {
this._elementRef.nativeElement.classList.add(`novo-field-type-${control.controlType}`);
this._elementRef.nativeElement.setAttribute('data-control-type', control.controlType);
Expand All @@ -128,6 +127,10 @@ export class NovoFieldElement implements AfterContentInit, OnDestroy {
this._elementRef.nativeElement.setAttribute('data-control-id', control.id);
}

if (control.ngControl?.name) {
this._elementRef.nativeElement.setAttribute('data-control-key', control.ngControl.name);
}

// Subscribe to changes in the child control state in order to update the form field UI.
// tslint:disable-next-line:deprecation
control.stateChanges.pipe(startWith(null)).subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { AbstractConditionFieldDef } from './abstract-condition.definition';
<novo-field *novoConditionInputDef="let formGroup; fieldMeta as meta" [formGroup]="formGroup">
<novo-select formControlName="value" [placeholder]="labels.select" [multiple]="true">
<!-- WHat about optionUrl/optionType -->
<novo-option *ngFor="let option of meta?.options" [value]="option.value">
<novo-option *ngFor="let option of meta?.options" [value]="option.value" [attr.data-automation-value]="option.label">
{{ option.label }}
</novo-option>
</novo-select>
Expand Down

0 comments on commit 4cb454b

Please sign in to comment.