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

Stricter 'value' type for list items #21

Open
CaptainCodeman opened this issue Dec 26, 2022 · 2 comments
Open

Stricter 'value' type for list items #21

CaptainCodeman opened this issue Dec 26, 2022 · 2 comments

Comments

@CaptainCodeman
Copy link
Owner

It's a little "loosey-goosey" right now, using "any" for the value but really expecting / treating things as a string in some places.

It either needs to be a string consistently or could allow an object if the component is also provided with a "get me the string value" function.

This would also allow stricter lint checks.

@CaptainCodeman
Copy link
Owner Author

It's nice to be able to use "any" object for the item data, but some components need to match on string values. So if the item value isn't a string, and it may not always make sense to use the textContent of the item elements, we need to provide a property name or selector function to extract the value.

@bertramdesigns
Copy link

Any more thoughts on this? I have run into a situation that has caused a bit of confusion.

It seems that when you call $menu.active it returns the text value of (node: HTMLElement). So if I have something like the following:

{#each projectItems as project, i}
	{@const menuID = 'menuItem-' + (i + 1)}
	<a use:menu.item href="" id={menuID}>content {i} 
		<span>extra fancy stuff</span>
	</a>
{/each}

$menu.active would return "content # extra fancy stuff"

In a situation where the menu has more banner-like items that include additional content this could become verbose and complicated, especially if the banners are components.

Given it is possible to control the id and that "aria-activedescendant" is identified based on the item id would it make sense to include something like $menu.activeID to return this id for easier addressing and identifying the active element?

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

No branches or pull requests

2 participants