Skip to content

Commit

Permalink
Changed approach to aria-label as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefcdias committed Jan 22, 2021
1 parent 0b1d8a6 commit 0eeb71e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { Announced } from '@fluentui/react';
import { DatePicker } from '@fluentui/react-date-time';
import { DefaultButton } from '@fluentui/react/lib/compat/Button';
import { mergeStyleSets } from '@fluentui/react/lib/Styling';
Expand All @@ -15,11 +14,9 @@ const onFormatDate = (date?: Date): string => {

export const DatePickerFormatExample: React.FunctionComponent = () => {
const [value, setValue] = React.useState<Date | undefined>();
const [clearedAnnounced, setClearedAnnounced] = React.useState<JSX.Element | undefined>();

const onClick = React.useCallback((): void => {
setValue(undefined);
setClearedAnnounced(<Announced message="Input field cleared" aria-live="assertive" />);
}, []);

const onParseDateFromString = React.useCallback(
Expand Down Expand Up @@ -58,8 +55,7 @@ export const DatePickerFormatExample: React.FunctionComponent = () => {
parseDateFromString={onParseDateFromString}
className={styles.control}
/>
{clearedAnnounced}
<DefaultButton onClick={onClick} text="Clear" />
<DefaultButton aria-label="Clear the date input" onClick={onClick} text="Clear" />
<div>Selected date: {(value || '').toString()}</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { Announced } from '@fluentui/react';
import { DefaultButton } from '@fluentui/react/lib/compat/Button';
import { DatePicker, IDatePicker } from '@fluentui/react-date-time';
import { mergeStyleSets } from '@fluentui/react/lib/Styling';
Expand All @@ -12,11 +11,9 @@ const styles = mergeStyleSets({
export const DatePickerInputExample: React.FunctionComponent = () => {
const [value, setValue] = React.useState<Date | undefined>();
const datePickerRef = React.useRef<IDatePicker>(null);
const [clearedAnnounced, setClearedAnnounced] = React.useState<JSX.Element | undefined>();

const onClick = React.useCallback((): void => {
setValue(undefined);
setClearedAnnounced(<Announced message="Input field cleared" aria-live="assertive" />);
}, []);

return (
Expand All @@ -35,8 +32,7 @@ export const DatePickerInputExample: React.FunctionComponent = () => {
componentRef={datePickerRef}
className={styles.control}
/>
{clearedAnnounced}
<DefaultButton onClick={onClick} text="Clear" />
<DefaultButton aria-label="Clear the date input" onClick={onClick} text="Clear" />
</div>
);
};

0 comments on commit 0eeb71e

Please sign in to comment.