Setting SfTab.SelectedItem after Page Load Results in Unexpected Scroll

Please see this SLN:

https://github.com/Mike-E-angelo/Stash/tree/master/Syncfusion.Tabs

Upon launching, press the Click Me button.

Expected: page does not scroll

Actual: page scrolls

I do not see any attribute to control this behavior.  Any guidance/insight/suggestions would be appreciated.


15 Replies

VR Vijay Ravi Syncfusion Team June 27, 2023 12:37 PM UTC

Hi Mike,


Refer the below code snippet with "Click Me" button. The button click event handler OnClick() is implemented to enable scrolling on subsequent clicks. The _index variable is set to 1 to select the second tab, and tabRef.SelectAsync(_index) is used to programmatically select the tab. The onSelected() event handler is used to focus the "Click Me" button after the tab selection. Let us know if you need any further assistance.


[index.razor]


 

<Syncfusion.Blazor.Buttons.SfButton @ref="btnClick" CssClass="button small" type="button" OnClick="@OnClick">Click Me</Syncfusion.Blazor.Buttons.SfButton>

 

<SfTab @ref="tabRef" CssClass="default-tab e-fill">

    <TabEvents  Selected="onSelected"></TabEvents>

    <TabItems>

        <TabItem>

            <ChildContent>

                <TabHeader Text="First"></TabHeader>

            </ChildContent>

        </TabItem>

        <TabItem>

            <ChildContent>

                <TabHeader Text="Second"></TabHeader>

            </ChildContent>

           

        </TabItem>

        <TabItem>

            <ChildContent>

                <TabHeader Text="Third"></TabHeader>

            </ChildContent>

        </TabItem>

    </TabItems>

</SfTab>

 

 

@code {

    SfButton btnClick;

    SfTab tabRef;

    int _index;

    Task OnClick()

    {

        _index = 1;

        tabRef.SelectAsync(_index);

        return Task.CompletedTask;

    }

 

    public void onSelected(SelectEventArgs args)

    {

        btnClick.FocusAsync();

    }

 

}



Regards,

Vijay Ravi


Attachment: blazor_tabs_b00c821a.zip


MI Mike-E June 27, 2023 12:47 PM UTC

Hi Vijay,


Thank you for your reply.  Unfortunately, there is some confusion about my report.  The issue is that when the Click Me button in the solution I provided is pressed, the page scroll changes, can you please confirm?  If so, this is unexpected.  Further, why does this happen for any index besides 0 but not on zero?  I would like to disable this functionality and do not see any way to control it.

Thank you,

Michael



SK Satheesh Kumar Balasubramanian Syncfusion Team June 28, 2023 07:39 AM UTC

Hi Mike,

We have checked your query and let you know that selected tab item will get focus when you select the tab item through SelectedItem two way binding property and SelectAsync public method which is the default behavior of tabs. So, only the page is scrolled down and navigate to selected tab item. If you want to prevent this page scroll, use SelectAsync public method to select the tab item and you can focus the button in tab Selected event as shown in the previous update. Since, Selected event will not trigger when using SelectedItem two way binding property. So, only we have used SelectAsync public method to select the tab item.

Please get back to us if you need any further assistance.

Regards,
Satheesh Kumar B


MI Mike-E June 28, 2023 08:12 AM UTC

Thank you for your reply, Satheesh.  

To start, please do not worry about the button.  The button is only there to invoke unexpected behavior.  In the actual case that I am experiencing in production, the user clicks on a link within the SfTab of the tab control, and then presses the back button on their browser/mouse.  I am also storing that tab control's SelectedItem in sessionStorage.  When it is bound to that control, after the page has loaded, the scroll is no longer accurate due to other items on the page having loaded and scrolled down.  

The user is then left in a confusing place which leads to a poor experience.

Unfortunately, this behavior seems backward to me.  It would seem to me that the scroll should only occur when you invoke a method (SelectAsync), and that method should have a parameter of whether that scroll should be invoked.  Scrolling on a data-binding event seems unexpected and unintuitive and should at the least be controlled by an additional property on the control to prevent this behavior in situations such as what I am encountering.

Thank you for your consideration.



SK Satheesh Kumar Balasubramanian Syncfusion Team June 30, 2023 02:42 PM UTC

Hi Mike,


We confirmed your reported problem “Selecting SfTab item after page load results in unexpected scroll” as a bug and logged the defect report. The fix for this defect will be included in our upcoming weekly patch release, which is expected to be rolled out by July 12, 2023. You can track the status of the fix at the following link:


Feedback : https://www.syncfusion.com/feedback/44902/selecting-sftab-item-after-page-load-results-in-unexpected-scroll


Disclaimer: Inclusion of this solution in the weekly release

may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Satheesh Kumar B



MI Mike-E July 4, 2023 10:43 AM UTC

Thank you very much Satheesh and team for all your efforts out there!



RV Ravikumar Venkatesan Syncfusion Team July 5, 2023 05:47 AM UTC

Hi Mike,


You are welcome. We will let you know once the fix for the issue will be included.


Regards,

Ravikumar Venkatesan



SK Satheesh Kumar Balasubramanian Syncfusion Team July 31, 2023 11:43 AM UTC

Hi Mike,


We are glad to announce that our Essential Studio 2023 Volume 2 SP release v22.2.5 is rolled out and is available for download under the following link.


https://www.syncfusion.com/forums/183720/essential-studio-2023-volume-2-service-pack-release-v22-2-5-is-available-for-download

In this release, we have provided PreventFocus support in SelectEventArgs to prevent the focus while selecting the tab item. So we suggest upgrading your package version to the latest to avail of this fix. You can give PreventFocus value as true like this to prevent the focus while selecting the tab item.


public void onSelected(SelectEventArgs args)

{

        args.PreventFocus = true;

}

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,

Satheesh Kumar B



MI Mike-E August 13, 2023 12:50 PM UTC

HI Satheesh,


Thank you again for your assistance here.  I did try the latest version, and while it does attend to the reported issue, I still seem to be having scrollY state issues when the SelectedIndex is set on an SfTab control and I mouse back and forward on my pages.

Unfortunately I cannot provide a simple reproduction at the moment.  However, I wanted to inquire if there are any other scrollY operations that are performed by SfTab?


Thank you for any further assistance.



SK Satheesh Kumar Balasubramanian Syncfusion Team August 15, 2023 07:22 AM UTC

Hi Mike,

We suspect that you are selecting the tab item through SelectedItem two way binding property. We suggest you select the tab item through SelectAsync public method instead of SelectedItem property in the latest version to resolve the scroller issue. Since, the Selected event will not trigger when using SelectedItem two way binding property. So, only we have used SelectAsync public method to select the tab item.

[index.razor]


<SfTab @ref="tabRef" CssClass="default-tab e-fill">
    <TabEvents Selected="onSelected"></TabEvents>
    <TabItems>
        <TabItem>
            <ChildContent>
                <TabHeader Text="First"></TabHeader>
            </ChildContent>
        </TabItem>
        <TabItem>
            <ChildContent>
                <TabHeader Text="Second"></TabHeader>
            </ChildContent>
           
        </TabItem>
        <TabItem>
            <ChildContent>
                <TabHeader Text="Third"></TabHeader>
            </ChildContent>
        </TabItem>
    </TabItems>
</SfTab>


@code {
    int _index;
    SfTab tabRef;
    Task OnClick()
    {
        _index = 1;
        tabRef.SelectAsync(_index);
        return Task.CompletedTask;
    }
    public void onSelected(SelectEventArgs args)
    {
        args.PreventFocus = true;
    }
}

Regards,
Satheesh Kumar B

Attachment: Syncfusion.Tabs_cd970776.zip


MI Mike-E August 15, 2023 05:40 PM UTC

Thank you for the guidance and time Satheesh.


Are you saying then there is a scrollY adjustment occurring when a tab is selected even if PreventFocus = true?  If so, I again say that this is unexpected behavior.  I would greatly appreciate having a EnableAutomaticScrollFocus="false" attribute on the SfTab that disables all scrollY modifications on the page/document.  Thank you for your consideration of this.


Outside of this, if I was using your solution above, how do I know that the _index is 1 for the second tab? and _index  = 2 for the 3rd tab, and so on?


Thank you for your consideration and continued assistance. 



SK Satheesh Kumar Balasubramanian Syncfusion Team August 16, 2023 03:53 PM UTC

Hi Mike,

Based on our current tab architecture, we regret to inform you that it is not possible to provide a property like this EnableAutomaticScrollFocus="false". You can get the previous and current tab index details in SelectEventArgs. Based on the argument details, you can process your requirements.


Regards,
Satheesh Kumar B


MI Mike-E August 16, 2023 06:13 PM UTC

Thank you for your reply, Satheesh.  I hope you can understand the concern here of having the document scrollY modified unintentionally by any control, regardless of the SfTab.  It is unclear to me why such behavior is provided in SfTab and especially with such a common scenario as databinding.

Are you able to confirm if other control toolkits such as Telerik also enlist in such behavior as well?  I suppose I would understand better if this were the case.

Sorry for being such a nuisance, but the amount of work that I now have to do for your control to work as expected is making me look at other tab controls for a simpler solution. :(



SK Satheesh Kumar Balasubramanian Syncfusion Team August 17, 2023 01:52 PM UTC

Hi Mike,


We confirmed your reported problem “Prevent the unexpected scroll when selecting the SfTab item” as a bug and logged the defect report. The fix for this defect will be included in our upcoming weekly patch release, which is expected to be rolled out by August 29, 2023. You can track the status of the fix at the following link:


Feedback: https://www.syncfusion.com/feedback/46200/prevent-the-unexpected-scroll-when-selecting-the-sftab-item


Disclaimer: Inclusion of this solution in the weekly release

may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Satheesh Kumar B



SK Satheesh Kumar Balasubramanian Syncfusion Team September 21, 2023 10:21 AM UTC

Hi Mike,


We are glad to announce that our Essential Studio 2023 Volume 3 release v23.1.36 is rolled out and is available for download under the following link.


https://www.syncfusion.com/forums/184588/essential-studio-2023-volume-3-main-release-v23-1-36-is-available-for-download


The fix for the issue Tab Header was receiving focus during the selection of an SfTab item, leading to unexpected scrolling” has been included in our volume 3 release v23.1.36. Upgrade to the latest version to resolve the issue.



Regards,

Satheesh


Loader.
Up arrow icon