Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukicenturi committed May 24, 2024
1 parent dbdc232 commit 842b7a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/cypress/e2e/chip.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe('chip', () => {
cy.contains('h2[data-cy=chips]', 'Chips');

cy.get('[data-cy*=chip-0').first().as('dismissibleChip');
cy.get('[data-cy*=chip-6').first().as('disabledChip');
cy.get('[data-cy*=chip-12').first().as('inDismissibleChip');
cy.get('[data-cy*=chip-7').first().as('disabledChip');
cy.get('[data-cy*=chip-14').first().as('inDismissibleChip');

cy.get('@dismissibleChip').find('button').should('not.be.disabled');
cy.get('@dismissibleChip').find('button').trigger('click');
Expand Down
4 changes: 2 additions & 2 deletions example/cypress/e2e/forms/autocomplete.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ describe('forms/Auto Completes', () => {
cy.contains('h2[data-cy=auto-completes]', 'Auto Completes');
cy.get('div[data-cy=auto-complete-0]').as('firstAutoComplete');

cy.get('@firstAutoComplete').find('[data-id="activator"]').should('be.exist');
cy.get('@firstAutoComplete').should('be.exist');
cy.get('@firstAutoComplete').find('span[class*=_label_]').should('contain.text', 'Select');

cy.get('div[role=menu]').should('not.exist');

cy.get('@firstAutoComplete').find('[data-id="activator"]').click();
cy.get('@firstAutoComplete').click();

cy.get('div[role=menu]').should('be.visible');
cy.get('div[role=menu] button:first-child').click();
Expand Down
6 changes: 3 additions & 3 deletions src/composables/dropdown-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ export function useDropdownMenu<T, K extends keyof T>({
return itemIndexInValue(item) !== -1;
}

function adjustScrollByHighlightedIndex() {
function adjustScrollByHighlightedIndex(smooth: boolean = false) {
const index = get(highlightedIndex);
nextTick(() => {
const container = get(menuRef)?.parentElement;
if (container && index > -1) {
const highlightedElem = get(menuRef).getElementsByClassName('highlighted')[0];

if (highlightedElem) {
highlightedElem.scrollIntoView?.({ block: 'nearest' });
highlightedElem.scrollIntoView?.({ behavior: smooth ? 'smooth' : 'auto', block: 'nearest' });
if (get(autoFocus) && 'focus' in highlightedElem && typeof highlightedElem.focus === 'function')
highlightedElem?.focus();
}
Expand Down Expand Up @@ -184,7 +184,7 @@ export function useDropdownMenu<T, K extends keyof T>({
watch(highlightedIndex, (curr, prev) => {
if (curr !== prev) {
nextTick(() => {
adjustScrollByHighlightedIndex();
adjustScrollByHighlightedIndex(true);
});
}
});
Expand Down

0 comments on commit 842b7a7

Please sign in to comment.