← All changes
|
js/components/ManageMenu/SnippetsTable/SnippetsTableControls.tsx
+9
-11
3.10.0-beta.1
→
trunk
View file →
| @@ -1,6 +1,6 @@ | ||
| 1 | -import { __, sprintf } from '@wordpress/i18n' | |
| 2 | -import React, { Fragment, useMemo } from 'react' | |
| 1 | +import { __, _x, sprintf } from '@wordpress/i18n' | |
| 2 | +import React, { Fragment, useId, useMemo } from 'react' | |
| 3 | 3 | import { useRestAPI } from '../../../hooks/useRestAPI' |
| 4 | 4 | import { useSnippetsList } from '../../../hooks/useSnippetsList' |
| 5 | 5 | import { handleUnknownError } from '../../../utils/errors' |
| 6 | 6 | import { REST_BASES } from '../../../utils/restAPI' |
| @@ -44,15 +44,11 @@ | ||
| 44 | 44 | event.preventDefault() |
| 45 | 45 | setCurrentStatus(status) |
| 46 | 46 | }} |
| 47 | 47 | > |
| 48 | - {`${label} `} | |
| 49 | - <span className="count">{ | |
| 50 | - sprintf( | |
| 51 | - // translators: %d: number of snippets in the current view. | |
| 52 | - __('(%d)', 'code-snippets'), | |
| 53 | - snippetsByStatus.get(status)?.length ?? 0 | |
| 54 | - ) | |
| 48 | + {label} <span className="count">{ | |
| 49 | + // translators: %d: number of snippets in the current view. | |
| 50 | + sprintf(_x('(%d)', 'table view count', 'code-snippets'), snippetsByStatus.get(status)?.length ?? 0) | |
| 55 | 51 | }</span> |
| 56 | 52 | </a> |
| 57 | 53 | </li> |
| 58 | 54 | </Fragment>)} |
| @@ -87,8 +83,9 @@ | ||
| 87 | 83 | } |
| 88 | 84 | |
| 89 | 85 | const FilterByTagControl: React.FC<FilterByTagControlProps> = ({ visibleSnippets }) => { |
| 90 | 86 | const { currentTag, setCurrentTag } = useSnippetsFilters() |
| 87 | + const tagFilterId = useId() | |
| 91 | 88 | |
| 92 | 89 | const tagsList: Set<string> = useMemo( |
| 93 | 90 | () => visibleSnippets.reduce((tags, snippet) => { |
| 94 | 91 | snippet.tags.forEach(tag => tags.add(tag)) |
| @@ -97,15 +94,16 @@ | ||
| 97 | 94 | [visibleSnippets]) |
| 98 | 95 | |
| 99 | 96 | return 0 < tagsList.size |
| 100 | 97 | ? <div className="alignleft actions"> |
| 101 | - <label htmlFor="snippets-tag-filter" className="screen-reader-text"> | |
| 98 | + <label htmlFor={tagFilterId} className="screen-reader-text"> | |
| 102 | 99 | {__('Filter snippets by tag', 'code-snippets')} |
| 103 | 100 | </label> |
| 104 | 101 | <select |
| 105 | - id="snippets-tag-filter" | |
| 102 | + id={tagFilterId} | |
| 106 | 103 | name="tag" |
| 107 | 104 | value={currentTag} |
| 105 | + aria-label={__('Filter snippets by tag', 'code-snippets')} | |
| 108 | 106 | onChange={event => setCurrentTag(event.target.value)} |
| 109 | 107 | > |
| 110 | 108 | <option value="">{__('All Tags', 'code-snippets')}</option> |
| 111 | 109 | {[...tagsList].map(tag => |