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

Using a Menu instance instead of object config renders different #8666

Open
marciogurka opened this issue Feb 22, 2024 · 0 comments
Open

Using a Menu instance instead of object config renders different #8666

marciogurka opened this issue Feb 22, 2024 · 0 comments
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer

Comments

@marciogurka
Copy link

Forum post

Using a Menu instance directly inside the configuration makes the positioning not working correctly

  • Working snippet
let MainMenu = new Menu({

    autoClose: false,
    appendTo: 'container',
    floating: false,
    maxWidth: '150px',
    onItem: () => { console.log('Clicked') },
    items: [
        SubMenu, SubMenu2, {
            text: 'Menu Item 3',
            closeParent: false, 
            menu: {
                items    : [
                    {
                        icon : 'b-fw-icon b-icon-add',
                        text : 'Add'
                    },
                    {
                        icon : 'b-fw-icon b-icon-trash',
                        text : 'Remove'
                    },
                    {
                        icon     : 'b-fw-icon b-icon-lock',
                        disabled : true,
                        text     : 'I am disabled'
                    },
                    {
                        text : 'Sub menu',
                        menu : [{
                            icon : 'b-fw-icon b-fa-play',
                            text : 'Play'
                        }]
                    }
                ],
                // Method is called for all ancestor levels
                onItem({ item }) {
                    Toast.show('You clicked ' + item.text);
                }
            },
            onItem: () => { console.log('Submenu clicked 3') }
        }
    ]
});

Screenshot 2024-02-22 at 16 12 21

  • Non-working snippet
const menu = new Menu({
    items    : [
        {
            icon : 'b-fw-icon b-icon-add',
            text : 'Add'
        },
        {
            icon : 'b-fw-icon b-icon-trash',
            text : 'Remove'
        },
        {
            icon     : 'b-fw-icon b-icon-lock',
            disabled : true,
            text     : 'I am disabled'
        },
        {
            text : 'Sub menu',
            menu : [{
                icon : 'b-fw-icon b-fa-play',
                text : 'Play'
            }]
        }
    ],
    // Method is called for all ancestor levels
    onItem({ item }) {
        Toast.show('You clicked ' + item.text);
    }
});

let SubMenu = new MenuItem({
    text: 'Menu Item',
closeParent: false, 
    onItem: () => { console.log('Submenu clicked') }
});

let SubMenu2 = new MenuItem({
    text: 'Menu Item 2',
closeParent: false, 
    onItem: () => { console.log('Submenu clicked 2') }
});

let SubMenu3 = new MenuItem({
    text: 'Menu Item 3',
closeParent: false, 
menu: menu,
    onItem: () => { console.log('Submenu clicked 3') }
});

let MainMenu = new Menu({

    autoClose: false,
    appendTo: 'container',
    floating: false,
    maxWidth: '150px',
    onItem: () => { console.log('Clicked') },
    items: [
        SubMenu, SubMenu2, SubMenu3
    ]
});

Screenshot 2024-02-22 at 16 16 50

@marciogurka marciogurka added bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer labels Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer
Projects
None yet
Development

No branches or pull requests

1 participant