Comments (1)
Supporting key navigation and element focusing in vue
when the app loads, we need to select the first button
- here, we can make use of the
created
hook to know that the component is loaded, but it won't be ready to use just yet. The elements are added on screen via themounted
hook, which guarantees the HTML has been drawn on screen. - The app should grab focus upon load, then take control of keyboard presses from there on
*Remember not to use arrow functions for hooks, as The VueJS people know what this
is, and use it intentionally. If we need some async thing, we can use .bind(this)
as needed.
Support for keyboard navigation
Approach one
Tabbing currently works on the elements, but the arrow keys have no specific behavior. We have access to a global event listener on keydown
to detect keyboard presses, and a hook for incrementing and decrementing the item to focus on.
We need to modify start-button
to handle focus
based on an app index in such a way that tabbing and arrows do not get out of sync. We can capture all those key strokes in JS and allow the tab fallback.
- Tab / ArrowRight / ArrowDown will increment the position of the selected button and focus it
- Shift+Tab / ArrowLeft / ArrowUp will decrement the position of the selected button and focus it
- pressing any of the button keys mapped to each button should first focus, then activate the button
- Spacebar/Enter on any button should activate the currently selected button
We can use Vue directives potentially to handle this. if the app implements v-on:keypress
, we can route all keyboard events for the buttons. More on v-on directives
We should also consider using modifiers to prevent default behavior.
Highlighting selected option
We can use v-bind:class
to handle setting a focus state along with :focus
and :active
from start.
Related Issues (12)
- Add component tests HOT 1
- Decide whether to publish to current location or to some other app container HOT 1
- Move to Parcel HOT 1
- Remove & ignore package-lock.json
- Review component model
- Add edit functionality to app-level Vue object HOT 1
- Add keypress handlers for buttons HOT 1
- Planning for 0.x.0 releases HOT 1
- Add support for different keyboard layouts
- Port styles from old layout to new layout HOT 1
- Add ability to clear all data from local storage HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from start.