react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

[docs beta] "Scrolling to an element" example does not work on Safari

Open DiegoCardoso opened this issue 3 years ago • 1 comments

Checking the beta docs, I noticed that one of the examples was not working. At first it was not working at all, but after I added a style of overflow-x: auto to the <ul> element, then I could see the desired effect after clicking on the buttons. I could later check that the example works as expected (without any changes in Chrome). My first guess is that Safari doesn't scroll because the element has an implicit overflow as visible.

Please note that this issue is also present on the challenge 3, as it basically uses that same principle to scroll the images.

Steps

  1. Open https://beta.reactjs.org/learn/manipulating-the-dom-with-refs#example-scrolling-to-an-element on Safari
  2. Click on the buttons

DiegoCardoso avatar Jul 28 '22 20:07 DiegoCardoso

The culprit is the scrollIntoView(). The method is not fully supported by Safari. You can make it work partially by changing behavior: 'smooth' to behavior: 'auto' as smooth is not currently supported by Safari. [0]

[0] https://caniuse.com/?search=scrollIntoView

MostlyEmre avatar Aug 16 '22 15:08 MostlyEmre