Skip to content

Commit

Permalink
APP-3126: remove scrollIntoView mock (viamrobotics#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored Jan 5, 2024
1 parent 2468474 commit a6aff3c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"combobox",
"listbox",
"radiobox",
"unstub",
"viamrobotics"
]
}
1 change: 1 addition & 0 deletions packages/blocks/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export default defineConfig({
setupFiles: ['src/vitest.setup.ts'],
environment: 'jsdom',
mockReset: true,
unstubGlobals: true,
},
});
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@viamrobotics/prime-core",
"version": "0.0.77",
"version": "0.0.78",
"publishConfig": {
"access": "public"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/lib/select/searchable-select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ $: autoSelectOption = allOptions[autoSelectIndex] ?? otherOption;
$: isExpanded = menuState === FOCUS_SEARCH || menuState === FOCUS_ITEM;
$: activeOption = isExpanded ? autoSelectOption : undefined;
$: activeID = activeOption ? SELECTED_ID : undefined;
$: activeElement = activeOption
? optionElements[activeOption.option]
: undefined;
$: if (activeOption) {
optionElements[activeOption.option]?.scrollIntoView({ block: 'nearest' });
$: if (typeof activeElement?.scrollIntoView === 'function') {
activeElement.scrollIntoView({ block: 'nearest' });
}
const setMenuState = (nextMenuState: MenuState) => {
Expand Down
10 changes: 1 addition & 9 deletions packages/core/src/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { afterEach, vi } from 'vitest';
import { afterEach } from 'vitest';
import { cleanup } from '@testing-library/svelte';
import '@testing-library/jest-dom/vitest';

/**
* `Element.scrollIntoView` is not implemented/stubbed in `jsdom` so we stub it
* out here:
*
* https://github.com/jsdom/jsdom/issues/1695
*/
Element.prototype.scrollIntoView = vi.fn();

/**
* `PointerEvent` does not exist in `jsdom` so this polyfill is based off this
* comment on the PR to add it:
Expand Down
1 change: 1 addition & 0 deletions packages/core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfig({
setupFiles: ['src/vitest.setup.ts'],
environment: 'jsdom',
mockReset: true,
unstubGlobals: true,
// For testing svelte internals like onMount, see: https://github.com/vitest-dev/vitest/issues/2834
alias: [{ find: /^svelte$/u, replacement: 'svelte/internal' }],
},
Expand Down

0 comments on commit a6aff3c

Please sign in to comment.