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

Bug: inline if helper doesn't work when condition is an arg #1642

Open
NullVoxPopuli opened this issue Oct 29, 2024 · 2 comments
Open

Bug: inline if helper doesn't work when condition is an arg #1642

NullVoxPopuli opened this issue Oct 29, 2024 · 2 comments

Comments

@NullVoxPopuli
Copy link
Contributor

Reproduction:https://limber.glimdown.com/edit?c=JYWwDg9gTgLgBAYQuCA7Apq%2BAzKy4DkAAgOYA2oI6UA9AMbKQZYEDcAUKJLHAN5wwoAQzoBrdABM4AXzi58xcpWo1BI0cFQk27dg1QBneAHlRcALxwAPDHTgyQ2wD5TV1XbAPnHfUbgBpCAtrW3tHdCdAt1DPcKcOPTQ-ADEKMDBqYJsPLwj2OD5eYGw4ImADUzhKwOlpXQLeXgBiYtLy01r8gu6rSponLsb0MgN0Tu6ewLh%2Bwd4aYs7onLiE9AAPbngJdGwhAFcyeDoHAwM4ABE7IPXbVAkzpBRmeF4uojUxSTh2s0tdkfQHAK2DSwQAFABKCxOAQAC3KADofsEAIQweEGJEVUQJArZMLOLp41LAdKZMrY8yNdGIn61aYDCZWABGexgMDQcDQx2AYipvBpmJBpNqThJYDcrPZaEZ1ncBLy0iAA&format=gjs

Code:

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

const Ok = <template>Ok</template>;
const Ko = <template>Ko</template>;

const Flipper = <template>
  {{if @isOk Ok Ko}}

  {{#if @isOk}}
      <Ok />
  {{else}}
      <Ko />
  {{/if}}
</template>;

export default class Demo extends Component {
  @tracked isOk = false;
  flip = () => this.isOk = !this.isOk;

  <template>
    <Flipper @isOk={{this.isOk}} />
    <button onclick={{this.flip}}>Flip</button>
  </template>
}

Problem:

the inline if doesn't update its returned value when @isOk changes, but the block-form does.

@patricklx
Copy link
Contributor

It works with simple strings though.

@patricklx
Copy link
Contributor

patricklx commented Oct 29, 2024

I mean {{if @isOk 'ok' 'ko'}}
And

{{#let (if @isOk Ok Ko) as |okko|}}
    <okko/>
  {{/let}}

Maybe it's not supposed to render components from inline if.
Maybe helper would work.
{{if @isOk (ok) (ko)}}

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