Skip to content

Commit 9134102

Browse files
authored
fix: check both item and list disabled states (#15)
2 parents a8f791d + c2a2e42 commit 9134102

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

.github/workflows/release.yml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
default-branch: '${{ github.ref_name }}'
2121
changelog-notes-type: 'github'
2222
package-name: ng-keyboard-sort
23-
path: libs/ng-keyboard-sort
2423
token: ${{ secrets.GH_TOKEN }}
2524
changelog-types: >
2625
[
File renamed without changes.

libs/ng-keyboard-sort/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "ng-keyboard-sort",
3+
"description": "Angular keyboard sort directive",
34
"version": "1.0.2",
5+
"license": "MIT",
46
"repository": {
57
"type": "git",
68
"url": "https://github.com/johnhwhite/ng-keyboard-sort.git",
7-
"directory": "projects/ng-keyboard-sort",
8-
"branch": "main"
9+
"directory": "projects/ng-keyboard-sort"
910
},
1011
"peerDependencies": {
1112
"@angular/cdk": "^15.0.0",

libs/ng-keyboard-sort/src/lib/keyboard-sort-item.directive.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class KeyboardSortItemDirective implements AfterViewInit, OnDestroy {
9393
}
9494

9595
public activate() {
96-
if (!this.activated && !this.kbdSortItemDisabled) {
96+
if (!this.activated && !this.isDisabled()) {
9797
this.#list?.clearActivated();
9898
this.activated = true;
9999
this.#renderer.addClass(
@@ -116,11 +116,18 @@ export class KeyboardSortItemDirective implements AfterViewInit, OnDestroy {
116116
}
117117
}
118118

119+
public isDisabled(): boolean {
120+
if (this.kbdSortItemDisabled) {
121+
return true;
122+
}
123+
return !!this.#list?.kbdSortListDisabled;
124+
}
125+
119126
public moveUp(): boolean {
120127
if (!this.#list) {
121128
return false;
122129
}
123-
if (this.activated && !this.kbdSortItemDisabled) {
130+
if (this.activated && !this.isDisabled()) {
124131
return this.#list.moveItemUp(this);
125132
}
126133
return false;
@@ -130,7 +137,7 @@ export class KeyboardSortItemDirective implements AfterViewInit, OnDestroy {
130137
if (!this.#list) {
131138
return false;
132139
}
133-
if (this.activated && !this.kbdSortItemDisabled) {
140+
if (this.activated && !this.isDisabled()) {
134141
return this.#list.moveItemDown(this);
135142
}
136143
return false;
@@ -181,7 +188,7 @@ export class KeyboardSortItemDirective implements AfterViewInit, OnDestroy {
181188
fromEvent<KeyboardEvent>(elementRef.nativeElement, 'keydown')
182189
.pipe(
183190
filter((event) => {
184-
return !this.kbdSortItemDisabled && event.key.startsWith('Arrow');
191+
return !this.isDisabled() && event.key.startsWith('Arrow');
185192
})
186193
)
187194
.subscribe((event) => {

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ng-keyboard-sort",
33
"description": "Angular keyboard sort directive",
4-
"version": "0.0.0",
4+
"version": "1.0.2",
55
"license": "MIT",
66
"private": true,
77
"repository": {

0 commit comments

Comments
 (0)