-
Notifications
You must be signed in to change notification settings - Fork 211
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
[Bug]: Accessing value
of sp-menu-item before render throws an error
#3626
Comments
value
of sp-menu-item throws an errorvalue
of sp-menu-item before render throws an error
A quick test provides more evidence that it might be a race to the first render/update cycle. I changed this: private updateFocus(): void {
this.activeMenu()?.focus({ preventScroll: true });
}; to this: private async updateFocus(): Promise<void> {
const menu = this.activeMenu();
if (menu == null) return;
await menu.updateComplete;
menu.focus({ preventScroll: true });
}; ...and it resolved the issue. |
Hey @Westbrook, I tried this in the https://studio.webcomponents.dev/edit/fdpCdZN6Khei2agAcWud/src/index.ts?p=stories |
Looks like we addressed a similar context elsewhere, and then erroneously marked this as addressed for it. @najikahalsema is looking into a fix for this, soon! |
Code of conduct
Impacted component(s)
sp-menu-item
Expected behavior
No response
Actual behavior
Accessing a MenuItem's value before it has rendered can throw the following error:
Screenshots
No response
What browsers are you seeing the problem in?
No response
How can we reproduce this issue?
Sample code that illustrates the problem
No response
Logs taken while reproducing problem
No response
The text was updated successfully, but these errors were encountered: