enterprise-wc icon indicating copy to clipboard operation
enterprise-wc copied to clipboard

PopupMenu: SubMenu in PopupMenu not working as intended

Open tenacity00 opened this issue 2 years ago • 5 comments

Encountered this error when hovering the MenuItem to display the SubMenu.

image

Here's the rendered element: image

How can I fix this issue? Already tried setting a value for scrollLeft but still encountering the error.

tenacity00 avatar Apr 12 '24 12:04 tenacity00

@tenacity00 How would we be able to reproduce this?

  1. Try reproducing in the examples https://main.wc.design.infor.com/ids-popup-menu ? (i dont see it)
  2. Check your code against ours https://github.com/infor-design/enterprise-wc/tree/main/src/components/ids-popup-menu
  3. Try the latest version (beta.23)

Aside from that would need a reduced test case or way to see it in the examples? Also if that code can reproduce it please include it as text not a screen shot.

Worth Looking at: https://usersnap.com/blog/what-is-a-bug-report/

Suggestion based on quick look at the screen shot is remove: style: "position: absolute"

tmcconechy avatar Apr 12 '24 13:04 tmcconechy

Hi @tmcconechy, thank you so much for taking some time to answer my inquiry. when I use the dataset code: ( I'm using typescript )

const menu = new PopupMenu();
    menu.target = this.options.id;
    menu.triggerType = "click"
    menu.data = {
        id: this.options.id,
        contents: [
            {
                type: 'group',
                items: [
                    {
                        text: 'One',
                        value: '1',
                        type : 'item'
                    },
                    {
                        text: 'Two',
                        value: '2',
                        type : 'item'
                    },
                    {
                        text: 'Three',
                        value: '3',
                        type : 'item',
                        submenu: {
                          id:'submen',
                          contents : [{type: 'group',
                            items : [{
                              text : 'o1',
                              value : 'o1',
                              type: 'item'
                            }]
                          }]
                        }
                    },
                ]
            }
        ]
    }
    this.idsComponent.insertAdjacentElement("afterend", menu)

It's working properly, clicking the MenuButton, Displaying Menu, Displaying Sub Menu. But the PopupMenu is displaying upwards. image

But when I use this code:

    const menu = new PopupMenu();
    menu.id = this.options.id
    menu.target = this.options.id
    menu.triggerType = "click"

    const group = new IdsMenuGroup();
    menu.appendChild(group);

    const itemOne = new IdsMenuItem();
    itemOne.value = 1;
    itemOne.textContent = '1'
    group.appendChild(itemOne);

    const itemTwo = new IdsMenuItem();
    itemTwo.value = 2;
    itemTwo.textContent = '2'
    group.appendChild(itemTwo);

    const menu1 = new PopupMenu();
    menu1.id = this.options.id
    menu1.target = this.options.id
    menu1.triggerType = "click"
    // document.body.appendChild(menu);
    
    const group1 = new IdsMenuGroup();
    menu1.appendChild(group1);

    const itemOne1 = new IdsMenuItem();
    itemOne1.value = 1;
    itemOne1.textContent = '1'
    group1.appendChild(itemOne1);

    const itemTwo1 = new IdsMenuItem();
    itemTwo1.value = 2;
    itemTwo1.textContent = '2'
    group1.appendChild(itemTwo1);

    const itemThree = new IdsMenuItem();
    itemThree.value = 3;
    itemThree.textContent = '3'

    itemThree.appendChild(menu1);

    group.appendChild(itemThree);
    
    this.idsComponent.insertAdjacentElement("afterend", menu)

I received the scrollLeft error. and when I duplicate the this.idsComponent.insertAdjacentElement("afterend", menu) I didn't encounter the error. which I think is weird.

how to make it display downwards?

image

I'm on beta v21. upgraded it to v23 the issue still occurs.

I couldn't replicate it on: https://main.wc.design.infor.com/ids-popup-menu

tenacity00 avatar Apr 15 '24 15:04 tenacity00

@tenacity00 Wierd bug :). A couple initial observations and i'll try and work on this soon.

  1. Do you think you can make an example in https://stackblitz.com/edit/ids-enterprise-wc-beta-23?file=index.html so we can share the code better and debug?
  2. One wierd thing is your menu items looks really "short" do you have some css that could be changing the size of the menu items?
  3. in general it should open down because of this line https://github.com/infor-design/enterprise-wc/blob/main/src/components/ids-menu-button/ids-menu-button.ts#L222 which is how you configure the popup to open down
  4. Maybe its better to use the ids-menu-button component for your case? this way you dont need to configure it as much https://github.com/infor-design/enterprise-wc/blob/main/src/components/ids-menu-button/demos/example.html#L15-L18
  5. Maybe a problem of creating it dynamically in TS? Is that necessary for you?

tmcconechy avatar Apr 15 '24 16:04 tmcconechy

Hi @tmcconechy ,

Thank you.

  1. I placed the rendered element here and I was able to replicate the issue, I'm not sure what part of it I'm missing. https://stackblitz.com/edit/ids-enterprise-wc-beta-23-bb4wnt?file=index.html

  2. I reverted some of my changes and I think it's now displaying properly tho the SubMenu looks weird. image

  3. I'm appending the PopupMenu after rendering the IdsMenuButton {MenuButton}.insertAdjacentElement("afterend", menu )

  4. As of now yes, we're thinking of controlling it dynamically on the backend side.

tenacity00 avatar Apr 16 '24 12:04 tenacity00

@tenacity00 something is strange. I was able to make it work like this in our project but not in the stackblitz.

          <ids-menu-button
            id="btn-action"
            menu="btn-action-menu"
            dropdown-icon="dropdown"
            appearance="secondary">
            <span>Action</span>
          </ids-menu-button>
        <ids-popup-menu id="btn-action-menu">
          <ids-menu-group>
            <ids-menu-item>
              Add Work Order
              <ids-popup-menu slot="submenu">
                <ids-menu-group>
                  <ids-menu-item id="sub-menu6">
                    sub-menu6
                  </ids-menu-item>
                </ids-menu-group>
              </ids-popup-menu>
            </ids-menu-item>
            <ids-menu-item>
              Add Case
              <ids-popup-menu
                slot="submenu">
                <ids-menu-group>
                  <ids-menu-item id="sub-menu20">
                    <ids-text>sub-menu20</ids-text>
                  </ids-menu-item>
                </ids-menu-group>
              </ids-popup-menu>
            </ids-menu-item>
            <ids-menu-item>
              Duplicate Service Request
              <ids-popup-menu slot="submenu">
                <ids-menu-group>
                  <ids-menu-item>sub-menu92</ids-menu-item>
                </ids-menu-group>
              </ids-popup-menu>
            </ids-menu-item>
          </ids-menu-group>
        </ids-popup-menu>

You have a lot of uneeded stuff in there and the position style. But it wont work in the stackblitz. I thought this may indicate a missing import but i quickly checked and dont see any missing. I'll route this to another developer to take a look in the future but perhaps my snippet helps as it worked in my case in the actual project when i put it here:

https://github.com/infor-design/enterprise-wc/blob/main/src/components/ids-menu-button/demos/example.html

Note it uses these imports in that example:

https://github.com/infor-design/enterprise-wc/blob/main/src/components/ids-menu-button/demos/index.ts#L2-L8

tmcconechy avatar Apr 16 '24 14:04 tmcconechy

I am able to reproduce this in v1.0.0 with the official example.

Reproducible Demo Link: https://stackblitz.com/edit/ids-enterprise-wc-100-shbkbg?file=index.html Reference Official Example: https://main.wc.design.infor.com/ids-menu-button/disabled.html

Steps to reproducce:

  1. Access the demo link.
  2. Click on the Settings menu button and hover your mouse over the Settings submenu.
  3. Observe that the submenus "Sub-item One", etc. are not displayed.
  4. Open the browser's Developer Tools (the error will not appear in Stackblitz's console).
  5. Notice the error related to "scrollLeft".

I hope this helps investigating the issue easier.

Question: @tmcconechy, is there a temporary workaround while we wait for the fix.

kshwetabh avatar Apr 24 '24 05:04 kshwetabh

@kshwetabh I cant reproduce seem to reproduce it on https://main.wc.design.infor.com/ids-menu-button/disabled.html

Screenshot 2024-04-24 at 10 56 21 AM

For the stackblitz I didnt spend time going line by line but did you check if you missed something? I do see it there.

tmcconechy avatar Apr 24 '24 14:04 tmcconechy

@tmcconechy sorry for the confusion. I meant using the same code as used in the official IDS demo page, I am able to reproduce the issue in Stackblitz. The officcial IDS demo page works fine for me too.

I used the exact same code as used by the official demo page. I update the code further on stackblits to make it more minimalist and easier to review now. https://stackblitz.com/edit/ids-enterprise-wc-100-shbkbg?file=index.html

kshwetabh avatar Apr 25 '24 04:04 kshwetabh