md-tabs: Scrolls to top of page when tab is clicked
Clicking a new tab while using md-tabs will switch the tab but will also scroll the browser to the top of the page. Is this expected?
Tested on:
- Chrome
- Firefox
- Safari
Replicate: Codepen: http://codepen.io/anon/pen/pJXYbX
- Scroll to bottom
- Press Tab 3
- Notice it scrolls to the top.
Note: In this example only tab 3 does it. But it consistently happens when clicking any tab in my project.
+1
Also encountering this issue.
Not happening to me, what browser versions?
@SmoshySmosh It's scrolling me to the top of the tab but not the top of the page
@nathanmarks Looking at it again, you're right. On my site it looked like it scrolled all the way to the top of the page because you can just barely see the top of the tabs after you click to a new tab.
Still though, the problem remains that this is scrolling is unwanted and problematic for people who are trying to display important content with the md-tabs component.
I'm also seeing this issue on Firefox and Chrome.
angular-material 0.10.1 and angular 1.4.3.
I'm seeing this as well. For me it only happens when clicking on tabs further to the right. Clicking on a tab to the left of the active tab does not seem to trigger a scroll to the top.
This appears to be resolved now.
Reproduces in 0.11.4
@yarick333 - CodePen Demo please.
http://codepen.io/anon/pen/ojogER it only happens when clicking on tabs further to the right. Clicking on a tab to the left of the active tab does not seem to trigger a scroll to the top.
@robertmesserle - can your review ?
You need to add CSS:
.tabsdemoDynamicHeight md-content md-tabs {
border: 1px solid #e1e1e1;
}
All work then
Looking into this now. This only happens when md-dynamic-height is enabled, which makes me think it is due to a brief period where there is no content height while switching tabs. Looking into a way to make sure the height never flashes to 0 during this time.
I agree that it shouldn't scroll to the top of the entire page, but it should scroll to the top of the tabs themselves?
referring to my issue #5239
I have the same "scrolling to the top" problem on v1.0.6 for Safari when md-dynamic-height is enabled. On Chrome, it is working perfectly. Not very user friendly and quiet problematic for Safari users. Is there any turn around or fix ? I tried the fix proposed by @robertmesserle but it doesn't worked for me... Any idea guys ?
I opened a new issue #8065 showing the same problem with an animated gif. Tested on the actual Angular Material Demo website : https://material.angularjs.org/0.11.2/#/demo/material.components.tabs
Angular Material : Version 1.1.0-RC4 Angular : Version 1.4.8 Safari : Version 9.1
Problem still exists but only when tabs are paginated (with md-dynamic-height)... Using 1.1.0 RC5 with chrome...
+1
Problem seems to be fixed in Chrome 63, but present in Firefox 57.0.4.
AM 1.1.6. Angular 1.5 (Ionic bundled 1.3.2) Firefox 57.0.4 Mac OS X El Capitan
Only with md-tabs with md-dynamic-height as @r0b- stated.
Oddly, it only happens when clicking from the first tab to another.
Clicking from any other tab to any other tab doesn't trigger the scroll to top.
CONFIRMED, disabling the first tab with ng-disabled="$index == 0" fixes the issue in Firefox.
So a dirty work-around could be: disable the first tab (ng-disabled), and hide it with CSS (display:none — ng-show does not play well with ng-disabled). Of course you'll have to fix your ng-repeat accordingly, as well as your indexes or ids, since the first tab will now be a "ghost".
<md-tab
ng-repeat="item in data.items track by $index"
label="Item n°{{ $index }}"
ng-if="$index <= data.maximum_items"
ng-disabled="$index == 0"
ng-class="{'display_none': $index == 0}"
>
...
.md-tab.md-disabled{
display: none !important;
}