Tune aria-live regions around clocks/timers (#7735)

This commit is contained in:
Michael Telatynski 2022-02-08 11:20:03 +00:00 committed by GitHub
parent 4501308b47
commit 773c7f46b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View file

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from "react"; import React, { HTMLProps } from "react";
import { formatSeconds } from "../../../DateUtils"; import { formatSeconds } from "../../../DateUtils";
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
export interface IProps { export interface IProps extends Pick<HTMLProps<HTMLSpanElement>, "aria-live"> {
seconds: number; seconds: number;
} }
@ -40,6 +40,8 @@ export default class Clock extends React.Component<IProps> {
} }
public render() { public render() {
return <span className='mx_Clock'>{ formatSeconds(this.props.seconds) }</span>; return <span aria-live={this.props["aria-live"]} className='mx_Clock'>
{ formatSeconds(this.props.seconds) }
</span>;
} }
} }

View file

@ -61,6 +61,6 @@ export default class LiveRecordingClock extends React.PureComponent<IProps, ISta
} }
public render() { public render() {
return <Clock seconds={this.state.seconds} />; return <Clock seconds={this.state.seconds} aria-live="off" />;
} }
} }

View file

@ -76,6 +76,9 @@ export default class PlaybackClock extends React.PureComponent<IProps, IState> {
seconds = this.state.durationSeconds; seconds = this.state.durationSeconds;
} }
} }
return <Clock seconds={seconds} />; return <Clock
seconds={seconds}
aria-live={this.state.playbackPhase === PlaybackState.Playing ? "off" : undefined}
/>;
} }
} }

View file

@ -227,7 +227,7 @@ export default class CallEvent extends React.PureComponent<IProps, IState> {
if (state === CallState.Connected) { if (state === CallState.Connected) {
return ( return (
<div className="mx_CallEvent_content"> <div className="mx_CallEvent_content">
<Clock seconds={this.state.length} /> <Clock seconds={this.state.length} aria-live="off" />
{ this.props.timestamp } { this.props.timestamp }
</div> </div>
); );