Merge pull request #17031 from desktop/refresh-pull-request-feedback

Improve accessibility of refreshing pull requests
This commit is contained in:
tidy-dev 2023-07-19 18:43:45 +00:00 committed by GitHub
commit 514e8d01bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 19 deletions

View file

@ -21,6 +21,7 @@ import { startTimer } from '../lib/timing'
import { DragType } from '../../models/drag-drop'
import { dragAndDropManager } from '../../lib/drag-and-drop-manager'
import { formatRelative } from '../../lib/format-relative'
import { AriaLiveContainer } from '../accessibility/aria-live-container'
interface IPullRequestListItem extends IFilterListItem {
readonly id: string
@ -82,6 +83,7 @@ interface IPullRequestListState {
readonly filterText: string
readonly groupedItems: ReadonlyArray<IFilterListGroup<IPullRequestListItem>>
readonly selectedItem: IPullRequestListItem | null
readonly screenReaderStateMessage: string | null
}
function resolveSelectedItem(
@ -120,6 +122,7 @@ export class PullRequestList extends React.Component<
filterText: '',
groupedItems: [group],
selectedItem,
screenReaderStateMessage: null,
}
}
@ -130,27 +133,49 @@ export class PullRequestList extends React.Component<
nextProps,
this.state.selectedItem
)
this.setState({ groupedItems: [group], selectedItem })
const loadingStarted =
!this.props.isLoadingPullRequests && nextProps.isLoadingPullRequests
const loadingComplete =
this.props.isLoadingPullRequests && !nextProps.isLoadingPullRequests
const numPullRequests = this.props.pullRequests.length
const plural = numPullRequests === 1 ? '' : 's'
const screenReaderStateMessage = loadingStarted
? 'Hang Tight. Loading pull requests as fast as I can!'
: loadingComplete
? `${numPullRequests} pull request${plural} found`
: null
this.setState({
groupedItems: [group],
selectedItem,
screenReaderStateMessage,
})
}
public render() {
return (
<FilterList<IPullRequestListItem>
className="pull-request-list"
rowHeight={RowHeight}
groups={this.state.groupedItems}
selectedItem={this.state.selectedItem}
renderItem={this.renderPullRequest}
filterText={this.state.filterText}
onFilterTextChanged={this.onFilterTextChanged}
invalidationProps={this.props.pullRequests}
onItemClick={this.onItemClick}
onSelectionChanged={this.onSelectionChanged}
onFilterKeyDown={this.props.onFilterKeyDown}
renderGroupHeader={this.renderListHeader}
renderNoItems={this.renderNoItems}
renderPostFilter={this.renderPostFilter}
/>
<>
<FilterList<IPullRequestListItem>
className="pull-request-list"
rowHeight={RowHeight}
groups={this.state.groupedItems}
selectedItem={this.state.selectedItem}
renderItem={this.renderPullRequest}
filterText={this.state.filterText}
onFilterTextChanged={this.onFilterTextChanged}
invalidationProps={this.props.pullRequests}
onItemClick={this.onItemClick}
onSelectionChanged={this.onSelectionChanged}
onFilterKeyDown={this.props.onFilterKeyDown}
renderGroupHeader={this.renderListHeader}
renderNoItems={this.renderNoItems}
renderPostFilter={this.renderPostFilter}
/>
<AriaLiveContainer>
{this.state.screenReaderStateMessage}
</AriaLiveContainer>
</>
)
}
@ -289,11 +314,14 @@ export class PullRequestList extends React.Component<
}
private renderPostFilter = () => {
const tooltip = 'Refresh the list of pull requests'
return (
<Button
disabled={this.props.isLoadingPullRequests}
onClick={this.onRefreshPullRequests}
tooltip="Refresh the list of pull requests"
ariaLabel={tooltip}
tooltip={tooltip}
>
<Octicon
symbol={syncClockwise}

View file

@ -248,11 +248,14 @@ export class CloneableRepositoryFilterList extends React.PureComponent<ICloneabl
}
private renderPostFilter = () => {
const tooltip = 'Refresh the list of repositories'
return (
<Button
disabled={this.props.loading}
onClick={this.refreshRepositories}
tooltip="Refresh the list of repositories"
ariaLabel={tooltip}
tooltip={tooltip}
>
<Octicon
symbol={syncClockwise}