Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

3 lat temu
123456789101112131415161718192021222324252627
  1. # no-onchange
  2. Enforce usage of `onBlur` over/in parallel with `onChange` on select menu elements for accessibility. `onBlur` **should** be used instead of `onChange`, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users. `onBlur` is a more declarative action by the user: for instance in a dropdown, using the arrow keys to toggle between options will trigger the `onChange` event in some browsers. Regardless, when a change of context results from an `onBlur` event or an `onChange` event, the user should be notified of the change unless it occurs below the currently focused element.
  3. #### References
  4. 1. [onChange Event Accessibility Issues](http://cita.disability.uiuc.edu/html-best-practices/auto/onchange.php)
  5. 2. [onChange Select Menu](http://www.themaninblue.com/writing/perspective/2004/10/19/)
  6. ## Rule details
  7. This rule takes no arguments.
  8. ### Succeed
  9. ```jsx
  10. <select onBlur={updateModel}>
  11. <option/>
  12. </select>
  13. <select>
  14. <option onBlur={handleOnBlur} onChange={handleOnChange} />
  15. </select>
  16. ```
  17. ### Fail
  18. ```jsx
  19. <select onChange={updateModel} />
  20. ```