Skip to content

Dirty[] problem when using named slot forwarding and pass back prop. #6030

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

Closed
kkarpeev opened this issue Feb 27, 2021 · 3 comments
Closed

Dirty[] problem when using named slot forwarding and pass back prop. #6030

kkarpeev opened this issue Feb 27, 2021 · 3 comments

Comments

@kkarpeev
Copy link

kkarpeev commented Feb 27, 2021

Describe the bug
There is a reactivity problem when I use slot forwarding through the couple of components and passing props back.
The forwarded slot I use twice. One within {#if} block and the second one in {#each} (so slot it some template markup for Grid Component with inline editor). The one within #each renders normally. But when slot inside the #if condition appears, the parent component doesn't show markup within its own #if block (the condition involving passed back props is true, but the :else block is rendered).
I couldn't reproduce this bug in REPL example. But I tried. I've noted there a wrong behavior (see comments and console.log).

Can't attach the real component here, sorry. But the principle there is almost the same.
Here's what's generated from the real component:

There is a call of select_block_type(ctx, [-1]) at the line 262.
If I understand correctly: [-1] means that everything is dirty (all bit are 1's).
So dirty is an array with one element here.
And at the line 257 we have such precondition for #if block:
if (dirty[1] & 137494528)
And that's strange because there is no second element in dirty. So condition is always falsy.
Seems to be a bug.

Severity
Severe.
So thanks in advance for quick fix or some workaround hint.

Additional context
Note that slot in Comp2 in the repl example is used twice (just like in my real component). Maybe this somehow affects.
Also if I click at the div where :else content (inside < div slot="" > of parent component) is rendered, it immediately switches to #if block as it should be from the beginning. If this helps.

Generated code part ``` // (195:4)
function create_cellTemplate_slot(ctx) { let div; let t0;
let t1_value = (/*r*/ ctx[49] === -1
? console.log(/*mode*/ ctx[51], /*editorValues*/ ctx[52], /*row*/ ctx[47], /*col*/ ctx[48])
: "", "") + "";

let t1;
let t2;
let show_if;
let current_block_type_index;
let if_block;
let current;
const if_block_creators = [create_if_block, create_else_block];
const if_blocks = [];

function select_block_type(ctx, dirty) {

//HERE IS THE PROBLEM MAYBE
if (dirty[1] & /mode, editorValues, listItemData, col/ 137494528) show_if = !!([const__WEBPACK_IMPORTED_MODULE_5__.ENUM.MODE.LIST_EDITOR.CREATE, const__WEBPACK_IMPORTED_MODULE_5__.ENUM.MODE.LIST_EDITOR.MODIFY].includes(/mode/ ctx[51]) && /editorValues/ ctx[52][keyField] === /listItemData/ ctx[58][keyField] && !/col/ ctx[48].readonly);
if (show_if) return 0;
return 1;
}
//OR HERE
current_block_type_index = select_block_type(ctx, [-1]); //<--is [-1] correct? Because dirty[1] is undefined in this case.

if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
</details>


@kkarpeev
Copy link
Author

kkarpeev commented Feb 27, 2021

Oh, I think it may be the same as #4318.
Because the main problem is exactly the same: if goes to else (because of the dirty, I think).
upd: And #4263

@stale
Copy link

stale bot commented Jun 26, 2021

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 stale bot added the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 26, 2021
@stale stale bot removed the stale-bot label Jun 27, 2021
@dummdidumm
Copy link
Member

Closing as possible duplicate of #4318 . A reproduction, perhaps in form of a GitHub repository, would be appreciated as there's still no reproduction for this.

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

No branches or pull requests

4 participants