imba icon indicating copy to clipboard operation
imba copied to clipboard

Context is no longer passed to slots under teleports after upgrade to alpha.170

Open haikyuu opened this issue 4 years ago • 7 comments

Here is dropdown component

<self>
	<button type="button" @click=show>
		<slot>
		if isShown?
			<teleport to="#dropdown">
				<slot name="dropdown">

Usage

<dropdown>
      <span> "click me"
      <div slot="dropdown">
	      <main-menu>

The main-menu component no longer accesses context in that case. It was working in alpha 167

haikyuu avatar Sep 11 '21 14:09 haikyuu

Do you expect the main-menu #context to access properties on the dropdown, or the context in which it was created? Ie, do you want dropdown to be able to access #context.isShown?? I also need to rethink how events are supposed to flow via the teleport. Previously we wrapped teleported elements in a teleporting container, which was helpful for inheriting styling and keeping track of the context, but it seems better to be able to move elements directly into their teleport if possible.

somebee avatar Sep 13 '21 03:09 somebee

I think it makes sense for teleported children to be part of the flow of the tag that invoked the teleport (context, events ...). The main use cases for using teleport (modals, dropdowns, select menus ...) might need to use context data.

Accessing #context.isShown? seems not necessary. If I need it, I would pass it as a prop instead. In my case, I'm using context to access a property up in the tree currentPage

haikyuu avatar Sep 13 '21 20:09 haikyuu

I'll add some more tests for this and fix it. One of the biggest shortcomings of imba now is the test-suite. It doesn't test any SSR rendering etc, pretty bad.

somebee avatar Sep 14 '21 07:09 somebee

I'll add some more tests for this and fix it. One of the biggest shortcomings of imba now is the test-suite. It doesn't test any SSR rendering etc, pretty bad.

I could actually work on that. I will add an e2e test suite and I'll start with this issue.

haikyuu avatar Sep 14 '21 07:09 haikyuu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 13 '22 09:03 stale[bot]

unmarking as stale, handy feature :)

haikyuu avatar Jun 03 '22 03:06 haikyuu

Here is a scrim where it happens https://scrimba.com/scrim/c8GbkQfK

haikyuu avatar Jun 03 '22 03:06 haikyuu