2 Replies Latest reply on Nov 6, 2013 3:06 AM by Juraj Húska

    Disabled/Enabled RW - events propagation - questions

    Juraj Húska Master

      Hello guys, again me.

       

      I am testing disabled option of the pickList.

       

      When I set this option to true, than it is disabled as expected (disabled classes are rendered - user can not interact with it).

       

      However, when I am trying to interact with that pickList with JQuery, than it state is changed - I guess this is expected, as there is no way to avoid it, we can only disable the functionality which is achieved in standard way. Right ?

       

      But, what is kind of interesting is that change event is triggered even when working with such disabled pickList. Is this correct ? IMHO we can check before triggering of such event whether the RW is enabled. The question is whether it is needed ? I think it applies to all RWs.

       

      Cheers

      Juro

        • 1. Re: Disabled/Enabled RW - events propagation - questions

          Juro, what exactly do you mean by change event is triggered even when

          working with disabled pickList?

           

          Generally, when widget is disabled, user shouldn't be able to interact it,

          that's why it shouldn't produce change events.

           

          I guess an expection is a case where you use `setValue`-like method, when

          you change the state externally and want to update component even though

          interaction is disabled.

           

          Am I missing something?

           

          ~ Lukas

           

           

          On Tue, Nov 5, 2013 at 3:36 PM, Juraj Húska <jhuska@redhat.com> wrote:

           

          Hello guys, again me.

           

          I am testing disabled option of the pickList.

           

          When I set this option to true, than it is disabled as expected

          (disabled classes are rendered - user can not interact with it).

           

          However, when I am trying to interact with that pickList with JQuery,

          than it state is changed - I guess this is expected, as there is no way

          to avoid it, we can only disable the functionality which is achieved in

          standard way. Right ?

           

          But, what is kind of interesting is that change event is triggered

          even when working with such disabled pickList. Is this correct ? IMHO we

          can check before triggering of such event whether the RW is enabled. The

          question is whether it is needed ? I think it applies to all RWs.

           

          Cheers

          Juro

           

          Posted by forums

          Original post: https://community.jboss.org/message/844601#844601

          _______________________________________________

          richfaces-dev mailing list

          richfaces-dev@lists.jboss.org

          https://lists.jboss.org/mailman/listinfo/richfaces-dev

           

           

          • 2. Re: Re: Disabled/Enabled RW - events propagation - questions
            Juraj Húska Master

            Hopefully some code will speak better than words. Consider this snippet of testing disable option of a pickList.

             

            function test(fixture, element) {
                    // given
                    var changeCallback = jasmine.createSpy('changeCallback');
            
                    var options = {
                      disabled: true,
                      change: changeCallback
                    };
                    // when
                    element.pickList(options);
                   
                    // then - some interactions with pick list via JQuery - it changes the pickList (e.g. item is dragged)
                    runs(function () {
                      var firstSourceItem = element.find('.source .ui-selectee').first();
                      var firstTargetItem = element.find('.target .ui-selectee').first();
                      pickListFragment.dragItem(firstSourceItem, 400, 20);
                      pickListFragment.dragItem(firstTargetItem, -400, 20);
                      pickListFragment.selectItem(firstSourceItem);
                      pickListFragment.clickAddButton(fixture);
                      pickListFragment.selectItem(firstTargetItem);
                      pickListFragment.clickRemoveButton(fixture);
                    });
            
                    //however, here I expect that the change callback was not called and it was even when pickList is disabled
                    runs(function () {
                      expect(changeCallback).not.toHaveBeenCalled();
                    });
            
                    options = {
                      disabled: false,
                    };
                    element.pickList(options);
            }
            

             

            Is that clear what I am trying to say now ? Am I missing something ?