Completed
Last Updated: 14 Nov 2024 09:26 by ADMIN
Release 7.0.0
n/a
Created on: 06 Aug 2024 09:07
Category: ToolBar
Type: Bug Report
1
Changing a button's Overflow parameter doesn't affect the overflow dropdown until the browser window is resized

Programmatic changes to the Overflow parameter of ToolBar items do not take effect until the user resizes the browser window. This is because the internal item collections are updated only during initialization and window resize.

A possible workaround is to recreate the ToolBar items when making changes to them.

Test Page with the workaround:

<TelerikToolBar Adaptive="true">
    @if (ShouldRenderToolBarItems)
    {
        <ToolBarButton>Foo</ToolBarButton>
        <ToolBarButton Overflow="@PrintOverflow">Print</ToolBarButton>
        <ToolBarButton>Bar</ToolBarButton>
    }
</TelerikToolBar>

<TelerikButton OnClick="TogglePrint">Toggle Print</TelerikButton>

@code {
    private ToolBarButton printButton = default!;
    private TelerikToolBar toolbar = default!;

    private ToolBarItemOverflow PrintOverflow { get; set; } = ToolBarItemOverflow.Auto;

    private bool ShouldRenderToolBar { get; set; } = true;
    private bool ShouldRenderToolBarItems { get; set; } = true;

    private async Task TogglePrint()
    {
        // Uncomment to enable the workaround
        //ShouldRenderToolBarItems = false;

        await Task.Delay(1);

        if (PrintOverflow == ToolBarItemOverflow.Always)
        {
            PrintOverflow = ToolBarItemOverflow.Auto;
        }
        else
        {
            PrintOverflow = ToolBarItemOverflow.Always;
        }

        ShouldRenderToolBarItems = true;
    }
}

1 comment
n/a
Posted on: 09 Aug 2024 12:52
Also working as workaround: Toggling property Adaptive off and on, with that Delay(1) inbetween