# WhileCount bug when using both GreaterThan and LessThan

**URL:** <https://forums.fusetools.com/t/whilecount-bug-when-using-both-greaterthan-and-lessthan/6965>\
**Category:** Bug Reports\
**Created:** [December 6, 2016, 9:57am UTC](https://forums.fusetools.com/t/whilecount-bug-when-using-both-greaterthan-and-lessthan/6965 "2016-12-06T09:57:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [December 6, 2016, 9:57am UTC](https://forums.fusetools.com/t/whilecount-bug-when-using-both-greaterthan-and-lessthan/6965/1 "2016-12-06T09:57:38Z")

</div>

Tested on local preview with Fuse 0.30, 0.29, 0.26 and 0.20.  
The following `WhileCount` trigger always evaluates to true, although it shouldn’t: `<WhileCount Items="{list}" GreaterThan="1" LessThan="4">`

Full code for repro:

```auto
<App>
    <JavaScript>
        var Observable = require('FuseJS/Observable');
        var displayList = Observable();

        function add() {
            displayList.add({});
        };

        function remove() {
            if (displayList.length > 0) {
                displayList.removeAt(0);
            }
        };

        module.exports = {
            list: displayList,
            count: displayList.count(),
            add: add,
            remove: remove
        };
    </JavaScript>
    <DockPanel>

        <StackPanel Dock="Top" Padding="10" ItemSpacing="10">
            <StackPanel Orientation="Horizontal" ItemSpacing="5" Alignment="HorizontalCenter">
                <Text Value="Items:" Alignment="Center" Color="#000" FontSize="32" />
                <Text Value="{count}" Alignment="Center" Color="#000" FontSize="32" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" ItemSpacing="10" Alignment="HorizontalCenter">
                <Panel Width="50" Height="50" Clicked="{remove}">
                    <Text Value="-" Alignment="Center" Color="#fff" FontSize="42" />
                    <Rectangle Color="#ff5722" CornerRadius="2" />
                </Panel>
                <Panel Width="50" Height="50" Clicked="{add}">
                    <Text Value="+" Alignment="Center" Color="#fff" FontSize="42" />
                    <Rectangle Color="#4caf50" CornerRadius="2" />
                </Panel>
            </StackPanel>
        </StackPanel>

        <Panel Dock="Top">
            <!-- <WhileEmpty Items="{list}">
                <Text Alignment="Center" TextAlignment="Center" Value="No items. Click the + button!" Margin="20" />
            </WhileEmpty> -->
            <WhileCount Items="{list}" GreaterThan="1" LessThan="4">
                <Text Alignment="Center" TextAlignment="Center" Value="Good going. Add some more!" Margin="20" />
            </WhileCount>
            <!-- <WhileCount Items="{list}" GreaterThan="3">
                <Text Alignment="Center" TextAlignment="Center" Value="Right on. Keep pushing!" Margin="20" />
            </WhileCount> -->
        </Panel>
        
        <WrapPanel Dock="Fill">
            <Each Items="{list}">
                <Circle Width="10" Height="10" Color="#18f" Margin="5" />
            </Each>
        </WrapPanel>

    </DockPanel>
</App>

```

---

<div class="post-metadata">

**Author:** ![edA-qa\_mort-ora-y](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/eda-qa_mort-ora-y/32/124_2.png) [@edA-qa\_mort-ora-y](https://forums.fusetools.com/u/edA-qa_mort-ora-y)\
**Post date:** [December 6, 2016, 10:00am UTC](https://forums.fusetools.com/t/whilecount-bug-when-using-both-greaterthan-and-lessthan/6965/2 "2016-12-06T10:00:01Z")

</div>

I don’t see anythign immediately wrong with your code, so I’ll take a look further at Fuse.

---

<div class="post-metadata">

**Author:** ![edA-qa\_mort-ora-y](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/eda-qa_mort-ora-y/32/124_2.png) [@edA-qa\_mort-ora-y](https://forums.fusetools.com/u/edA-qa_mort-ora-y)\
**Post date:** [December 7, 2016, 7:20am UTC](https://forums.fusetools.com/t/whilecount-bug-when-using-both-greaterthan-and-lessthan/6965/3 "2016-12-07T07:20:01Z")

</div>

I’ve found the problem. The multiple conditions are essentially being treated as or conditions at the momoent, not and conditiosn. Technically it was only meant to support a single condition.

I’ll extend/fix it to work more like `WhileFloat`.
