Skip to content

Commit

Permalink
Merge pull request #1322 from GSA/input-clear
Browse files Browse the repository at this point in the history
Clear icon added to the input component
  • Loading branch information
yerramshilpa authored Oct 19, 2023
2 parents 15d5cc7 + 5944752 commit 229f27a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions libs/packages/sam-formly/src/lib/formly/formly.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
chevronDown,
infoCircleFill,
calendar,
x,
} from 'ngx-bootstrap-icons';
import { UsaAccordionModule, UsaFileInputModule } from '@gsa-sam/ngx-uswds';
import { IconModule } from '@gsa-sam/ngx-uswds-icons';
Expand Down Expand Up @@ -175,6 +176,7 @@ export const DATE_FORMAT: MatDateFormats = {
chevronDown,
infoCircleFill,
calendar,
x,
}),
FormlyModule.forChild(FORMLY_CONFIG),
FormlyModule.forRoot({
Expand Down
20 changes: 17 additions & 3 deletions libs/packages/sam-formly/src/lib/formly/types/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@ import { FieldType } from '@ngx-formly/core';

@Component({
selector: 'sds-formly-field-input',
template: `
template: ` <div class="maxw-mobile-lg position-relative">
<input
[ngClass]="{
'usa-input--disabled': to.disabled,
'usa-input--error': showError
}"
class="usa-input"
class="usa-input padding-right-3"
[placeholder]="to.placeholder"
name="input-success"
[formlyAttributes]="field"
[type]="to.inputType ? to.inputType : 'text'"
[formControl]="formControl"
/>
`,
<ng-container *ngIf="field.formControl.value">
<span class="position-absolute right-105 top-1 cursor-pointer bg-white">
<span
role="button"
aria-label="Clear input"
(click)="field.formControl.reset()"
(keyup.enter)="field.formControl.reset()"
tabindex="0"
class="icon-container"
>
<usa-icon [icon]="'x'" size="lg" class="font-sans-xs"></usa-icon>
</span>
</span>
</ng-container>
</div>`,
})
export class FormlyFieldInputComponent extends FieldType {}

0 comments on commit 229f27a

Please sign in to comment.