mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
Add keyboard navigation for users, groups, branches, tags, sources, changesets and plugins (#2153)
Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
committed by
GitHub
parent
da71004dd0
commit
eea60deadb
@@ -88,7 +88,7 @@ describe("shortcutIterator", () => {
|
||||
expect(result.error).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should call last callback upon pressing forward in initial state", async () => {
|
||||
it("should call first callback upon pressing forward in initial state", async () => {
|
||||
const callback = jest.fn();
|
||||
const callback2 = jest.fn();
|
||||
const callback3 = jest.fn();
|
||||
@@ -101,12 +101,12 @@ describe("shortcutIterator", () => {
|
||||
|
||||
Mousetrap.trigger("j");
|
||||
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
expect(callback2).not.toHaveBeenCalled();
|
||||
expect(callback3).toHaveBeenCalledTimes(1);
|
||||
expect(callback3).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should call first callback once upon pressing backward in initial state", async () => {
|
||||
it("should call last callback once upon pressing backward in initial state", async () => {
|
||||
const callback = jest.fn();
|
||||
const callback2 = jest.fn();
|
||||
const callback3 = jest.fn();
|
||||
@@ -117,12 +117,11 @@ describe("shortcutIterator", () => {
|
||||
</Wrapper>
|
||||
);
|
||||
|
||||
Mousetrap.trigger("k");
|
||||
Mousetrap.trigger("k");
|
||||
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
expect(callback2).not.toHaveBeenCalled();
|
||||
expect(callback3).not.toHaveBeenCalled();
|
||||
expect(callback3).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should not allow moving past the end of the callback array", async () => {
|
||||
|
||||
@@ -57,7 +57,7 @@ export const KeyboardIteratorContextProvider: FC<{ initialIndex?: number }> = ({
|
||||
|
||||
const navigateBackward = useCallback(() => {
|
||||
if (activeIndex.current === -1) {
|
||||
activeIndex.current = 0;
|
||||
activeIndex.current = callbacks.current.length - 1;
|
||||
executeCallback(activeIndex.current);
|
||||
} else if (activeIndex.current > 0) {
|
||||
activeIndex.current -= 1;
|
||||
@@ -67,7 +67,7 @@ export const KeyboardIteratorContextProvider: FC<{ initialIndex?: number }> = ({
|
||||
|
||||
const navigateForward = useCallback(() => {
|
||||
if (activeIndex.current === -1) {
|
||||
activeIndex.current = callbacks.current.length - 1;
|
||||
activeIndex.current = 0;
|
||||
executeCallback(activeIndex.current);
|
||||
} else if (activeIndex.current < callbacks.current.length - 1) {
|
||||
activeIndex.current += 1;
|
||||
|
||||
Reference in New Issue
Block a user