Announcement

Collapse
No announcement yet.

adjustButtons not fired

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • adjustButtons not fired

    Version: 8.2.2



    Steps:
    1. show smallDetail dialog
    2. edit in smallEdit dialog
    3. close smallEdit dialog

    Causes difficulties when using third-party libraries that base their rendering on the visibility of elements. At the moment, there are no events like afterShow and the only safe method is to override adjustButtons.

  • #2
    afterRender does not help - in the case of a dialog, it is called before the elements become visible

    Comment


    • #3
      Could not reproduce.

      Comment


      • #4
        I'll try to explain in more detail

        1. when a small detail view is called through an action in the list view, then adjustButtons is called several times and the key call occurs here - https://github.com/espocrm/espocrm/b.../modal.js#L384 after this.dialog.show();

        2. When a small detail view is appear after small edit view is closed "after:render" is not fired and adjustButtons() in that place is not fired. (https://github.com/espocrm/espocrm/b.../modal.js#L375)

        Comment


        • #5
          The key point is that in this place (https://github.com/espocrm/espocrm/b.../modal.js#L375) the adjustButtons call occurs in a visible dialogue, and all the rest - in a hidden one. And accordingly, it is impossible to calculate the actual parameters of the visible view area


          reproduced on any list view.

          Set breakpoint at devtool on https://github.com/espocrm/espocrm/b.../modal.js#L384 and make 3 steps:
          1. Open any entity from list (debugger stoped on this point)
          2. Hit edit button (another stop)
          3. Close edit form, doesn't matter via save or cancel : no stop in debugger
          Last edited by dimyy; 04-11-2024, 01:30 PM.

          Comment


          • #6
            But where is the bug? It's not called. But should it be? Is it possible to reproduce the problem that buttons are not rounded without any manipulation with DOM?

            Comment


            • #7
              The problem that adjustButtons was called for the hidden modal while the edit modal was displayed? If yes, what invoked this call?

              Comment


              • #8
                The problem is that the custom function "A" needs to be called after the div (in this case SmallDetailView) becomes visible.

                The div is made visible by dialog.show() and the only function that is called after dialog.show is adjustButtons .

                Thus, in order to make safe customization, calll of the function "A' must be thrown into custom adjustButtons.

                But in the case when smalldetail is shown after smalledit calling adjustButtons after dialog.show() does not happen. Also after:render for smalldetail not fired​.

                adjustButtons after smallEdit invoked at showButton and at showActionItem
                Last edited by dimyy; 04-11-2024, 02:25 PM.

                Comment


                • #9
                  Ok. This is not a bug and a completely different problem that it appeared to me initially.

                  Comment


                  • #10
                    I apologize for misleading you and not being able to convey the idea. Although the lack of after:render after the reappearance and change of data can be considered a bug.

                    Comment


                    • #11
                      You can just add another this.on('after:render', () => {}); in the setup method and it will be called after the modal is rendered. Does not solve the problem, but completely removes "adjustButtons" out of the question.

                      Comment


                      • #12
                        One may consider as a bug almost everything. There's no render, the modal is not rendered. The class 'hidden' is added and removed.

                        Comment


                        • yuri
                          yuri commented
                          Editing a comment
                          As your code or lib relies on the DOM, which can be considered as bit dirty. you can come up with some dirty solution that fires a code whenever the class is removed.

                      • #13
                        The MutationObserver interface provides the ability to watch for changes being made to the DOM tree. It is designed as a replacement for the older Mutation Events feature, which was part of the DOM3 Events specification.

                        Comment


                        • #14
                          I looked in the direction of the MutationObserver, but it looks too much like crutches.
                          I suspect that this is a more beautiful option - it may be useful in the future​

                          At the same view where adjustButtons customization

                          Code:
                                  actionEdit: function() {
                                      return Dep.prototype.actionEdit.call(this).then((view)=>{
                                          this.listenToOnce(view, 'remove', () => {
                                              this.adjustButtons();
                                          });
                                      });
                                  }​

                          Comment


                          • #15
                            To be consistent this, we would need to add many such crutches for every possible modal view. Including sub-sub-sub views. It's not good for the product. We should not add code for every peculiar use case. It's not good.

                            Comment


                            • dimyy
                              dimyy commented
                              Editing a comment
                              You are absolutely right
                          Working...
                          X