Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
FDS-290 aria-placeholder support added
Browse files Browse the repository at this point in the history
  • Loading branch information
vikas-cldcvr committed Feb 27, 2024
1 parent 23fc36c commit fcdc753
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ export class FDateTimePicker extends FRoot {
protected willUpdate(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
super.willUpdate(changedProperties);
this.role = "textbox";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export class FEmojiPicker extends FRoot {
protected willUpdate(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
super.willUpdate(changedProperties);
this.role = "textbox";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
if (!changedProperties.has("value") || !this.picker) {
/**
* initiate picker component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ export class FFileUpload extends FRoot {
super.willUpdate(changedProperties);
this.role = "button";
this.tabIndex = 0;
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}

render() {
Expand Down
1 change: 1 addition & 0 deletions packages/flow-core/src/components/f-icon/f-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class FIcon extends FRoot {
this.role = "img";
if (!this.getAttribute("aria-label"))
this.setAttribute("aria-label", "" + this._originalSource);
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
}

render() {
Expand Down
1 change: 1 addition & 0 deletions packages/flow-core/src/components/f-input/f-input-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class FInputLight extends FInputBase {
protected willUpdate(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
super.willUpdate(changedProperties);
this.role = "textbox";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}

render() {
Expand Down
1 change: 1 addition & 0 deletions packages/flow-core/src/components/f-input/f-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class FInput extends FInputBase {
protected willUpdate(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
super.willUpdate(changedProperties);
this.role = "textbox";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}

render() {
Expand Down
1 change: 1 addition & 0 deletions packages/flow-core/src/components/f-search/f-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export class FSearch extends FRoot {
protected willUpdate(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
super.willUpdate(changedProperties);
this.role = "search";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}
render() {
return html` <f-div
Expand Down
1 change: 1 addition & 0 deletions packages/flow-core/src/components/f-select/f-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export class FSelect extends FRoot {
protected willUpdate(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
super.willUpdate(changedProperties);
this.role = "listbox";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}
/**
* apply styling to f-select options wrapper.
Expand Down
1 change: 1 addition & 0 deletions packages/flow-core/src/components/f-suggest/f-suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ export class FSuggest extends FRoot {
}
super.willUpdate(changedProperties);
this.role = "textbox";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class FTextArea extends FRoot {
super.willUpdate(changedProperties);
this.role = "textbox";
this.ariaMultiLine = "true";
if (this.placeholder) this.setAttribute("aria-placeholder", this.placeholder);
}
render() {
const parentDiv = this.parentElement?.tagName === "F-DIV" ? this.parentElement : "";
Expand Down
4 changes: 4 additions & 0 deletions packages/flow-core/src/mixins/components/f-root/f-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export class FRoot extends LitElement {
this.setAttribute("aria-describedby", "flow-tooltip");
}
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
}
protected updated(changedProperties: PropertyValues) {
super.updated(changedProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ export async function validateField(
if (!silent) {
updateMessage(element, message, field, "data-qa-error-for");
element.state = "danger";
element.setAttribute("aria-invalid", "true");
}
} else {
element.setAttribute("aria-invalid", "false");
const helpSlot = element.querySelector("[slot='help']");
if (field.helperText) {
if (typeof field.helperText === "string") {
Expand Down
1 change: 1 addition & 0 deletions stories/flow-core/f-color-picker.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
export const Playground = {
render: (args: Record<string, unknown>) => {
return html`<f-color-picker
aria-label="Color Picker"
.variant=${args.variant}
.state=${args.state}
.size=${args.size}
Expand Down

0 comments on commit fcdc753

Please sign in to comment.