mirror of
https://github.com/desktop/desktop
synced 2024-09-17 23:21:55 +00:00
Merge pull request #17031 from desktop/refresh-pull-request-feedback
Improve accessibility of refreshing pull requests
This commit is contained in:
commit
514e8d01bc
|
@ -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}
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue