-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add autoscroll boolean prop (#1160)
* feat: add autoscroll boolean prop Fixes #449 * refactor: update autoscroll implementation Closes #1028 Closes #910 * refactor: only call maybeAdjustScroll in the watcher * docs: upgrade vuepress
- Loading branch information
Showing
7 changed files
with
2,415 additions
and
2,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { mountDefault } from "../helpers"; | ||
|
||
describe("Automatic Scrolling", () => { | ||
it("should check if the scroll position needs to be adjusted on up arrow keyUp", async () => { | ||
// Given | ||
const Select = mountDefault(); | ||
const spy = jest.spyOn(Select.vm, "maybeAdjustScroll"); | ||
Select.vm.typeAheadPointer = 1; | ||
|
||
// When | ||
Select.find({ ref: "search" }).trigger("keydown.up"); | ||
await Select.vm.$nextTick(); | ||
|
||
// Then | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should check if the scroll position needs to be adjusted on down arrow keyUp", async () => { | ||
// Given | ||
const Select = mountDefault(); | ||
const spy = jest.spyOn(Select.vm, "maybeAdjustScroll"); | ||
Select.vm.typeAheadPointer = 1; | ||
|
||
// When | ||
Select.find({ ref: "search" }).trigger("keydown.down"); | ||
await Select.vm.$nextTick(); | ||
|
||
// Then | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should check if the scroll position needs to be adjusted when filtered options changes", async () => { | ||
// Given | ||
const Select = mountDefault(); | ||
const spy = jest.spyOn(Select.vm, "maybeAdjustScroll"); | ||
Select.vm.typeAheadPointer = 1; | ||
|
||
// When | ||
Select.vm.search = "two"; | ||
await Select.vm.$nextTick(); | ||
|
||
// Then | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should not adjust scroll position when autoscroll is false", async () => { | ||
// Given | ||
const Select = mountDefault({ | ||
autoscroll: false | ||
}); | ||
const spy = jest.spyOn(Select.vm, "maybeAdjustScroll"); | ||
Select.vm.typeAheadPointer = 1; | ||
|
||
// When | ||
Select.vm.search = "two"; | ||
await Select.vm.$nextTick(); | ||
|
||
// Then | ||
expect(spy).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters