Skip to content

Commit 905a2a9

Browse files
author
Bart van den Ende
committed
Merge branch 'release/1.2.1'
2 parents 99c9906 + 665430e commit 905a2a9

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Use data properties with a domId string reference to determine the focus action
5050
```
5151

5252
### JS Component binding
53-
Use vue bind directive with a component function reference to determine the focus action during navigation
53+
Use vue bind directive with a component function reference to determine the focus action during navigation.
54+
Note that the available Vue events (@down, @up, @right, @left, @click) only work on Vue components not on native html elements!
5455
```html
5556
<Component id="button1" v-focus @down="componentFunctionDown"></Component>
5657
<Component id="button2" v-focus @up="componentFunctionUp" ></Component>
@@ -88,6 +89,7 @@ In case the page is just rendered and or focus is reset the directive should kno
8889

8990
### Enter action
9091
When a user actions an 'enter' keypress it will automatically be converted into a click action on the element that has active focus. So you can use the regular vue @click bindings.
92+
Note that by default vue only supports @click on html elements and you have to normally use @click.native on a component, this directive will automatically capture the native event though and convert it into a vue event so you can use @click for both native keyboard and mouse clicks.
9193
```html
9294
<Component id="button1" v-focus @down="componentFunctionDown"></Component>
9395
<Component id="button2" v-focus @up="componentFunctionUp" @click="button2clicked"></Component>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"unit": "jest --config test/unit/jest.conf.js --coverage",
3636
"release": "release-it --github.release --npm.publish --non-interactive",
3737
"release-minor": "release-it --github.release --npm.publish --non-interactive --increment minor",
38-
"release-major": "release-it --github.release --npm.publish --non-interactive --increment major"
38+
"release-major": "release-it --github.release --npm.publish --non-interactive --increment major",
39+
"release-patch": "release-it --github.release --npm.publish --non-interactive --increment patch"
3940
},
4041
"devDependencies": {
4142
"gulp": "^3.9.1",

src/navigation.service.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ export class NavigationService {
5050

5151
// action spatial navigation
5252
if (keyName in NavigationServiceDirection) this.spatialNavigationAction(<NavigationServiceDirection>keyName);
53-
54-
return true;
5553
}));
5654
}
5755

@@ -62,8 +60,6 @@ export class NavigationService {
6260

6361
let el = this.findFocusable(<HTMLElement>e.target);
6462
if (el) el.focus();
65-
66-
return false;
6763
});
6864

6965
// enable mouseout event
@@ -72,14 +68,20 @@ export class NavigationService {
7268

7369
let el = this.findFocusable(<HTMLElement>e.target);
7470
if (el) el.blur();
71+
});
7572

76-
return false;
73+
74+
// enable click event
75+
document.addEventListener("click", (e: MouseEvent) => {
76+
if (this.blockAllSpatialNavigation) return false;
77+
let el = this.findFocusable(<HTMLElement> e.target);
78+
if (el) el.enter();
7779
});
7880

7981
}
8082

8183
// try to find focusable element on mouse hover or click
82-
private findFocusable(target: Element): FocusElement | undefined {
84+
findFocusable(target: Element): FocusElement | undefined {
8385
// inside loop search for focusable element
8486
// we need this if the focusable element has children inside
8587
// so e.target can point to child or grandchild of focusable element
@@ -95,7 +97,7 @@ export class NavigationService {
9597
}
9698

9799
// action a new spatial navigation action
98-
private spatialNavigationAction(action: NavigationServiceDirection) {
100+
spatialNavigationAction(action: NavigationServiceDirection) {
99101
let el = this.getFocusElementInFocus();
100102

101103
let keyValue = NavigationServiceDirection[action];

0 commit comments

Comments
 (0)