ic-design-system icon indicating copy to clipboard operation
ic-design-system copied to clipboard

Whole page moves when switching tabs on website code examples

Open GCHQ-Developer-847 opened this issue 10 months ago • 3 comments

Summary of the bug

When you switch between the "Web component" and "React" tabs on the website on a lot of the component Code pages, the whole page moves up and down.

🪜 How to reproduce

  1. Go to one of the component Code pages (seems to happen on most of them) e.g. switch page, and scroll down to one of the code examples further down the page.
  2. Click between the "React" and "Web component" tabs on the code examples.
  3. See that the whole page jolts up and down as you change between the tabs (it is more serious on some pages than others).

📸 Screenshots or code

https://github.com/user-attachments/assets/6beb040f-aab7-4076-b681-a8dbddaadfd3

🧐 Expected behaviour

It would be best if the page doesn't move at all. It is not a nice user experience and can be confusing for the user as they will wonder what has happened / where they have moved to on the page.

Additional info

Users may not actually see this issue very frequently; users who only want to see the "Web components" tab will not see it all, users who want to see the "React" tab would see it once per page.

The issue doesn't seem to happen on the v2 website.

GCHQ-Developer-847 avatar Feb 25 '25 10:02 GCHQ-Developer-847

Proposal: Set a height on the code-preview window (with overflow:scroll) so that switching between wc/react doesn't change height of all code previews on page

Make sure that the addition of vertical scroll to these text areas (which already have a horizontal scroll) doesn't breach Reflow and it's insistence on one dimension scrolling

Added a point for investigating best solution

GCHQ-Developer-299 avatar Mar 03 '25 10:03 GCHQ-Developer-299

an alternative solution may be to store the scrollTop when the button is clicked & reset it to this value afterwards, so long as this does not make the experience too unpleasant

ad9242 avatar Mar 13 '25 10:03 ad9242

Might be useful to look at the code Ionic use to resolve this issue

GCHQ-Developer-847 avatar Mar 13 '25 11:03 GCHQ-Developer-847