Skip to content

Commit ef60a0f

Browse files
merging all conflicts
2 parents 737282e + 23b242e commit ef60a0f

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed

content/community/tools-starter-kits.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ Ready to grow boilerplate with react-router, redux, saga, webpack 3, jest w/ cov
3636
* **[EDGE Platform](https://github.com/sebastian-software/edge)** Universal React/SSR + Apollo GraphQL + JS/CSS Code Splitting + Fine-Tuned Webpack + Localization/Internationalization. Most things are external dependencies. Boilerplate available.
3737
* **[bae](https://github.com/siddharthkp/bae)** Zero config toolkit. SSR (with data fetching) + routing + streaming + styling (with styled-components) + HMR out of the box.
3838
* **[breko-hub](https://github.com/tomatau/breko-hub)** A production ready boilerplate for universal react applications. Complete with code splitting, server render (using koa), redux, sagas, debugging, hot-reloading (live updates on the server), css-modules, scss, super fast integration tests and unit tests. There's also a big focus on clean code and smaller files.
39+
* **[appseed](https://github.com/rosoftdeveloper/appseed)** A production ready boilerplate for UI-Ready react applications. The frontend can be bundled with various backends: Flask, Laravel, Express.

content/docs/accessibility.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ như hình dưới đây:
167167

168168
<img src="../images/docs/keyboard-focus.png" alt="Blue keyboard focus outline around a selected link." />
169169

170+
<<<<<<< HEAD
170171
Chỉ khi sử dụng CSS mới có thể remove outline này, ví dụ như
171172
chỉnh `outline: 0`, nếu bạn muốn thay thế nó với một focus outline khác.
172173
### Cơ chế skip đến nội dung mong muốn {#mechanisms-to-skip-to-desired-content}
@@ -200,6 +201,34 @@ widgets](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-nav
200201
DOM elements](/docs/refs-and-the-dom.html).
201202
Sử dụng nó, chúng ta đầu tiên tạo một ref đến một element
202203
trong JSX của một component class:
204+
=======
205+
Only ever use CSS that removes this outline, for example by setting `outline: 0`, if you are replacing it with another focus outline implementation.
206+
207+
### Mechanisms to skip to desired content {#mechanisms-to-skip-to-desired-content}
208+
209+
Provide a mechanism to allow users to skip past navigation sections in your application as this assists and speeds up keyboard navigation.
210+
211+
Skiplinks or Skip Navigation Links are hidden navigation links that only become visible when keyboard users interact with the page. They are very easy to implement with internal page anchors and some styling:
212+
213+
- [WebAIM - Skip Navigation Links](https://webaim.org/techniques/skipnav/)
214+
215+
Also use landmark elements and roles, such as `<main>` and `<aside>`, to demarcate page regions as assistive technology allow the user to quickly navigate to these sections.
216+
217+
Read more about the use of these elements to enhance accessibility here:
218+
219+
- [Accessible Landmarks](https://www.scottohara.me/blog/2018/03/03/landmarks.html)
220+
221+
### Programmatically managing focus {#programmatically-managing-focus}
222+
223+
Our React applications continuously modify the HTML DOM during runtime, sometimes leading to keyboard focus being lost or set to an unexpected element. In order to repair this, we need to programmatically nudge the keyboard focus in the right direction. For example, by resetting keyboard focus to a button that opened a modal window after that modal window is closed.
224+
225+
MDN Web Docs takes a look at this and describes how we can build [keyboard-navigable JavaScript widgets](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets).
226+
227+
To set focus in React, we can use [Refs to DOM elements](/docs/refs-and-the-dom.html).
228+
229+
Using this, we first create a ref to an element in the JSX of a component class:
230+
231+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
203232
```javascript{4-5,8-9,13}
204233
class CustomTextInput extends React.Component {
205234
constructor(props) {
@@ -230,11 +259,15 @@ input một cách rõ ràng bằng cách sử dụng DOM API nguyên bản
230259
this.textInput.current.focus();
231260
}
232261

262+
<<<<<<< HEAD
233263
```
234264
Đôi khi một component cha cần được set focus vào một element
235265
trong component con. Chúng ta có thể thực hiện bằng cách [phơi bày DOM refs tới
236266
component
237267
cha](/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components)
268+
=======
269+
Sometimes a parent component needs to set focus to an element in a child component. We can do this by [exposing DOM refs to parent components](/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components) through a special prop on the child component that forwards the parent's ref to the child's DOM node.
270+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
238271
239272
thông qua một prop đặc biệt ở component con để chuyển tiếp
240273
ref của component cha đến DOM node của component con.
@@ -260,6 +293,30 @@ class Parent extends React.Component {
260293
261294
// Bây giờ bạn có thể set focus khi cần thiết.
262295
this.inputElement.current.focus();
296+
<<<<<<< HEAD
297+
=======
298+
```
299+
300+
When using a HOC to extend components, it is recommended to [forward the ref](/docs/forwarding-refs.html) to the wrapped component using the `forwardRef` function of React. If a third party HOC does not implement ref forwarding, the above pattern can still be used as a fallback.
301+
302+
A great focus management example is the [react-aria-modal](https://github.com/davidtheclark/react-aria-modal). This is a relatively rare example of a fully accessible modal window. Not only does it set initial focus on
303+
the cancel button (preventing the keyboard user from accidentally activating the success action) and trap keyboard focus inside the modal, it also resets focus back to the element that initially triggered the modal.
304+
305+
>Note:
306+
>
307+
>While this is a very important accessibility feature, it is also a technique that should be used judiciously. Use it to repair the keyboard focus flow when it is disturbed, not to try and anticipate how
308+
>users want to use applications.
309+
310+
## Mouse and pointer events {#mouse-and-pointer-events}
311+
312+
Ensure that all functionality exposed through a mouse or pointer event can also be accessed using the keyboard alone. Depending only on the pointer device will lead to many cases where keyboard users cannot use your application.
313+
314+
To illustrate this, let's look at a prolific example of broken accessibility caused by click events. This is the outside click pattern, where a user can disable an opened popover by clicking outside the element.
315+
316+
<img src="../images/docs/outerclick-with-mouse.gif" alt="A toggle button opening a popover list implemented with the click outside pattern and operated with a mouse showing that the close action works." />
317+
318+
This is typically implemented by attaching a `click` event to the `window` object that closes the popover:
319+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
263320
264321
```
265322
Khi sử dụng HOC để mở rộng components, [chuyển tiếp
@@ -338,6 +395,7 @@ constructor(props) {
338395
}
339396
}
340397
```
398+
<<<<<<< HEAD
341399
Điều này có thể hoạt động tốt cho người dùng với những thiết
342400
bị pointer, như chuột, nhưng thao tác nó với chỉ bàn phím sẽ khiến chức năng bị
343401
hư hỏng khi tab sang element tiếp theo
@@ -351,6 +409,15 @@ obscuring other screen elements." />
351409

352410
Chúng ta cũng có thể đạt được chức năng tương tự bằng cách sử
353411
dụng những event handlers thích hợp, như `onBlur``onFocus`:
412+
=======
413+
414+
This may work fine for users with pointer devices, such as a mouse, but operating this with the keyboard alone leads to broken functionality when tabbing to the next element as the `window` object never receives a `click` event. This can lead to obscured functionality which blocks users from using your application.
415+
416+
<img src="../images/docs/outerclick-with-keyboard.gif" alt="A toggle button opening a popover list implemented with the click outside pattern and operated with the keyboard showing the popover not being closed on blur and it obscuring other screen elements." />
417+
418+
The same functionality can be achieved by using an appropriate event handlers instead, such as `onBlur` and `onFocus`:
419+
420+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
354421
```javascript{19-29,31-34,37-38,40-41}
355422
class BlurExample extends React.Component {
356423
constructor(props) {
@@ -404,6 +471,7 @@ class BlurExample extends React.Component {
404471
}
405472
}
406473
```
474+
<<<<<<< HEAD
407475
Đoạn code cho thấy chức năng của cả con trỏ
408476
và bàn phím của người dùng. Cũng lưu ý rằng thêm thuộc tính `aria-*` vào để hỗ trợ
409477
người dùng. Đơn giãn hơn là để sự kiện bàn phím cho phép `arrow key` tương tác với
@@ -415,12 +483,24 @@ tùy chọn popover chưa được implement.
415483
phụ thuộc vào con trỏ và sự kiện từ chuột sẽ làm hỏng chức năng cho người dùng bàn phím. Luôn luôn
416484
test với bàn phím sẽ ngay lập tức phát hiện được những khu vực có vấn đề, sau đó
417485
có thể sửa bằng cách dùng những handler để nhận input từ bàn phím.
486+
=======
487+
488+
This code exposes the functionality to both pointer device and keyboard users. Also note the added `aria-*` props to support screen-reader users. For simplicity's sake the keyboard events to enable `arrow key` interaction of the popover options have not been implemented.
489+
490+
<img src="../images/docs/blur-popover-close.gif" alt="A popover list correctly closing for both mouse and keyboard users." />
491+
492+
This is one example of many cases where depending on only pointer and mouse events will break functionality for keyboard users. Always testing with the keyboard will immediately highlight the problem areas which can then be fixed by using keyboard aware event handlers.
493+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
418494
419495
## Những Widgets phức tạp hơn {#more-complex-widgets}
420496

497+
<<<<<<< HEAD
421498
Trải nghiệm người dùng phức tạp không nên khiến mức độ accessibilty bị giảm đi.
422499
Trong khi đó accessibility dễ đạt được nhất bằng cách code sát với HTML nhất có thể,
423500
Ngay cả với widget phức tạp nhất.
501+
=======
502+
A more complex user experience should not mean a less accessible one. Whereas accessibility is most easily achieved by coding as close to HTML as possible, even the most complex widget can be coded accessibly.
503+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
424504
425505
Ở đây chúng ta cần kiến thức từ [ARIA Roles](https://www.w3.org/TR/wai-aria/#roles) cũng như [ARIA States and Properties](https://www.w3.org/TR/wai-aria/#states_and_properties). Đây là những công cụ có sẵn những thuộc tính HTML đã được hỗ trợ đầy đủ trong JSX và cho phép chúng ta xây dựng một trang web accessibility đầy đủ, những React component có chức năng cao cấp.
426506

@@ -482,6 +562,7 @@ Cho đến thời điểm hiện tại, cách dễ nhất và cũng là một tr
482562
là kiểm tra toàn bộ trang web của bạn có thể tương tác và sử dụng được
483563
chỉ bằng bàn phím hay không. Chúng ta thực hiện điều này bằng cách:
484564

565+
<<<<<<< HEAD
485566
1. Tháo chuột của bạn ra khỏi máy tính.
486567
2. Sử dụng `Tab``Shift+Tab` để duyệt web.
487568
3. Sử dụng `Enter` để tương tác với những phần tử trong trang web.
@@ -492,13 +573,31 @@ chỉ bằng bàn phím hay không. Chúng ta thực hiện điều này bằng
492573
Chúng ta có thể kiểm tra một số chức năng accessibility trực tiếp trong code JSX.
493574
Thường thì bộ kiểm tra intellisense sẽ được cung cấp sẵn trong IDE cho những vai trò
494575
ARIA, states và properties. Chúng ta cũng có thể truy cập bằng những công cụ dưới đây:
576+
=======
577+
1. Disconnecting your mouse.
578+
1. Using `Tab` and `Shift+Tab` to browse.
579+
1. Using `Enter` to activate elements.
580+
1. Where required, using your keyboard arrow keys to interact with some elements, such as menus and dropdowns.
581+
582+
### Development assistance {#development-assistance}
583+
584+
We can check some accessibility features directly in our JSX code. Often intellisense checks are already provided in JSX aware IDE's for the ARIA roles, states and properties. We also have access to the following tool:
585+
586+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
495587
#### eslint-plugin-jsx-a11y {#eslint-plugin-jsx-a11y}
496588
[eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y)
497589
plugin cho ESLint cung cấp AST phản hồi AST về những vấn đề liên quan đến accessibility trong JSX của bạn. Nhiều IDE's cho phép bạn tích hợp trực tiếp vào code analysis và source code windows.
498590

591+
<<<<<<< HEAD
499592
[Create React App](https://github.com/facebookincubator/create-react-app) có plugin này
500593
với một tập hợp về những quy tắc kích hoạt. Nếu bạn muốn cho phép quy tắc accessibility hơn nữa,
501594
bạn có thể tạo một `.eslintrc` file trong root của project bằng nội dung sau đây:
595+
=======
596+
The [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) plugin for ESLint provides AST linting feedback regarding accessibility issues in your JSX. Many IDE's allow you to integrate these findings directly into code analysis and source code windows.
597+
598+
[Create React App](https://github.com/facebookincubator/create-react-app) has this plugin with a subset of rules activated. If you want to enable even more accessibility rules, you can create an `.eslintrc` file in the root of your project with this content:
599+
600+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
502601
```json
503602
{
504603
"extends": ["react-app", "plugin:jsx-a11y/recommended"],

content/docs/hooks-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ Note that in the above example we **need** to keep the function in the dependenc
656656

657657
### What can I do if my effect dependencies change too often? {#what-can-i-do-if-my-effect-dependencies-change-too-often}
658658

659-
Sometimes, your effect may be using reading state that changes too often. You might be tempted to omit that state from a list of dependencies, but that usually leads to bugs:
659+
Sometimes, your effect may be using state that changes too often. You might be tempted to omit that state from a list of dependencies, but that usually leads to bugs:
660660

661661
```js{6,9}
662662
function Counter() {

0 commit comments

Comments
 (0)