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

feat: automatically bring to focus ion-segment-button when clicked in scrollable segment #25367

Closed
3 tasks done
javebratt opened this issue May 27, 2022 · 4 comments · Fixed by #26285
Closed
3 tasks done
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@javebratt
Copy link

Prerequisites

Describe the Feature Request

Buttons in a scrollable ion-segment should become fully visible when clicked.

Currently when the user has a scrollable segment and clicks on a button that is not on focus the button doesn't scroll to appear fully on the screen:

segment-no-focus.mov

Ideally, when the user clicks on a button that is not fully on the screen it should be brought to appear fully on the screen, kind of like Crunchyroll does it:

segment-with-focus.mov

Describe the Use Case

I believe it's a good UX implementations for the users to not have to scroll to be able to see the full label of the selected ion-segment-button

Describe Preferred Solution

When the user clicks the button, it automatically scrolls and becomes fully visible.

Describe Alternatives

No response

Related Code

No response

Additional Information

This was reported as a bug back in 2019 #19976, setting it up now as a feature request because I see that the report is with a previous version of Ionic.

@votala
Copy link

votala commented Aug 5, 2022

I came up with this solution instead waiting on a fix. works on ios/android both modes
segmentChanged(e){
//<ion-segment (ionChange)="segmentChanged($event)">
setTimeout(() => {
const s=e.target.getBoundingClientRect();
const sw=(s.right-s.left);
for (const button of e.target.childNodes) {
if (button.className.indexOf('segment-button-checked')>-1) {
const bc=button.offsetLeft+(button.offsetWidth/2);
const diff=bc-(sw/2);
e.target.scrollTo({
left: diff,
behavior: 'smooth'
});
break;
}
}
}, 200);
}

@liamdebeasi
Copy link
Member

Hi everyone,

Here is a dev build if anyone is interested in testing the proposed fix:

6.3.7-dev.11668459335.15b98d0a

@liamdebeasi
Copy link
Member

Thanks for the issue. This has been resolved via #26285, and a fix will be available in an upcoming release of Ionic Framework. Please feel free to continue testing the fix and let me know if you run into any issues.

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 16, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants