material-components / material-components/material-web
scrollable md-tabs: align active element to the middle
Nobody has claimed this yet.
- Dominant language
- SCSS
- Stars
- 11.3k
- Forks
- 1.1k
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 13
Description
### What is affected?
Component
### Description
with scrollable md-tabs, when I click on a tab it is automatically placed at the end of the container.
I think the best way is to place it in the middle of the container
### Reproduction
https://material-web.dev/components/tabs/stories/
### Workaround
I tried to edit scrollToTab function by inserting this
tabToScrollTo.scrollIntoView({
behavior: 'smooth',
block: 'nearest',
inline: 'center'
});
and it works pretty well
### Is this a regression?
No or unsure. This never worked, or I haven't tried before.
### Affected versions
1.2.0
### Browser/OS/Node environment
Chrome on Windows, Chrome on Android
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior in the linked md-tabs story with a scrollable tab set, then trace the component's scrollToTab function. Compare the current placement with the proposed centered scrolling behavior and verify that selecting tabs keeps the active tab centered without breaking scrolling on Chrome desktop and Android.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100