Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox): refresh behavior of the list and position #719

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

var-poro
Copy link
Contributor

@var-poro var-poro commented Mar 7, 2025

No description provided.

@var-poro var-poro marked this pull request as ready for review March 7, 2025 13:03
@var-poro var-poro requested a review from a team as a code owner March 7, 2025 13:03
left: '0',
top: `${y}px`,
});
if (!this.isOpen || !this.resultListElement) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done twice (see first instruction of RaF)

@@ -52,6 +52,7 @@ export class OdsCombobox implements OdsFormElement {
@State() private hasNoResults: boolean = false;
@State() private isInvalid: boolean | undefined;
@State() private isOpen: boolean = false;
@State() private items: ResultElement[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is only meant to force a refresh of the element list when slot change.
Plus you just pass its ref to this.resultElements anyway.

If we do want to update the list without closing the list, we could just use the forceUpdate method to trigger a rerender.

I wonder even if it could be better to close and the reopen the dropdown when items change so that it isi visible by the user, otherwise the contents he is currently on, is suddenly modified (then the isOpen state will trigger the refresh)

return;
}

this.resultListElement.classList.remove('ods-combobox__results--bottom', 'ods-combobox__results--top');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be duplicated, idealy it should be done on close, and we should always close and reopen, but it's TBD as mentionned on the state comment.

Object.assign(this.resultListElement.style, {
bottom: `${this.searchHeight}px`,
left: '0',
top: 'auto',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed?

});
} else {
Object.assign(this.resultListElement.style, {
bottom: 'auto',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed?

@@ -366,6 +367,23 @@ export class OdsCombobox implements OdsFormElement {
this.closeDropdown();
}

private hasDiff(oldItems: ResultElement[], newItems: ResultElement[]): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to move it into the controller and add unit tests

await inputEl.click();
await page.waitForChanges();

// Verify dropdown is open
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep only meaningful comments

});

it('should maintain correct positioning when reopening the dropdown', async() => {
// Similar setup as above
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picture each tests as independant, if test above is removed one day, this comment gets wrong

@@ -228,4 +306,4 @@ describe('ods-combobox rendering', () => {
expect(hasScroll).toBe(false);
});
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check your IDE to avoid removing last line automatically (or we'll have a diff each time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants