Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions plugins/field-date/src/field_date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,32 @@ export class FieldDate extends Blockly.FieldTextInput {
return getLocaleDateString(value);
}

/**
* Returns a description of the type of this field for screenreaders.
*/
override getAriaTypeName() {
return Blockly.Msg['ARIA_TYPE_FIELD_DATE'];
}

/**
* Returns a description of the current date for use by screenreaders.
*/
override getAriaValue() {
const stringValue = this.getValue();
if (!stringValue) return super.getAriaValue();

const date = new Date(stringValue);
// Use a localized long-form description of the date, e.g. January XX, 20XX,
// rather than a short-form/ISO version of the date which may be read out
// with slashes or the like.
return date.toLocaleDateString(undefined, {
year: 'numeric',
month: 'long',
day: 'numeric',
timeZone: 'UTC',
});
}

/**
* Renders the field. If the picker is shown make sure it has the current
* date selected.
Expand Down
Loading