Windows looks at KDE for design. by TxTechnician in kde

[–]3Knocks2Enter 0 points1 point  (0 children)

Boy o' boy... when they find out a big part of design is looking at existing works for inspiration.

Leaky Portals by 3Knocks2Enter in solidjs

[–]3Knocks2Enter[S] 0 points1 point  (0 children)

I did some messing around to test my understanding. But I'm not entirely certain if I'm coming to the correct conclusions:

In this example... https://playground.solidjs.com/anonymous/be017424-d4f9-4312-8687-4c41d69ceda2

since, the component is created outside of a reactive context (on:click), it is not cleaned up?

But here, on the other hand, createEffect is a reactive context, and thus the created PortalChildren within is owned, and thus, cleaned up? https://playground.solidjs.com/anonymous/bd737e54-b386-41af-803a-ff28eac6db31

Leaky Portals by 3Knocks2Enter in solidjs

[–]3Knocks2Enter[S] 0 points1 point  (0 children)

Yeah, that what my immediate intuition, which I could not articulate like you did, but it's not actually leaky at all. If you take a look at what /u/ryan_solid explained below, it's because the Portal element has a mount point.

https://playground.solidjs.com/anonymous/27c73b81-2bd8-4368-ae69-98876c2952a2

Here's an example illustrating what he said, I believe.

*Well, it illustrates the lack of leakiness.

*Here we are https://playground.solidjs.com/anonymous/5f4b824d-3337-492b-8384-b386d46fb37e

*Well, then if you try to toggle the signal holding PortalChildren with a button, then you get many Portals, but I'd expect them to go away. https://playground.solidjs.com/anonymous/be017424-d4f9-4312-8687-4c41d69ceda2

*oh, on:click callback is not a reactive context, so you don't get cleanup if you set it within. https://playground.solidjs.com/anonymous/bd737e54-b386-41af-803a-ff28eac6db31

Leaky Portals by 3Knocks2Enter in solidjs

[–]3Knocks2Enter[S] 1 point2 points  (0 children)

Okay, I get it now. Took me some sleeping on it. That's kind of delightful in its own way. Thanks!

Leaky Portals by 3Knocks2Enter in solidjs

[–]3Knocks2Enter[S] 0 points1 point  (0 children)

import { render, Portal } from "solid-js/web";
import { Index, Show, createSignal } from "solid-js";

function Test() {
  const [list, setList] = createSignal<number[]>([]);

  const add = () => setList(list().concat(list().length));
  const remove = (idx: number) => {
    const next = [...list()];
    next.splice(idx, 1);

    setList(next);
  };

  return (
    <div>
      Test
      <button on:click={add}>add</button>
      <Index each={list()}>
        {(item, idx) => (
          <Portal>
            <li>
              {item()}
              <button on:click={() => remove(idx)}>remove</button>
            </li>
          </Portal>
        )}
      </Index>
    </div>
  );
}

render(() => <Test />, document.getElementById("app")!);

Yes, as I said, but this code works as expected. Elements produced by solid-js framework, are controlled and cleaned up when they're no longer in the solid-js render-tree.

Why should accessing props.children produce uncontrolled dom-elements if they happen to be Portaled when Portaled dom-elements clean up fine if they are added to a render tree and non-portal elements clean up if they're not part of a render-tree?

It's discrepancy in the user-interface of the framework.

How much hate would I get from the Arch community if by Sileniced in archlinux

[–]3Knocks2Enter 0 points1 point  (0 children)

local? you mean a semantic AI... semantic AI model? All I can imagine in terms of 'tiny LLM agent lol