Sfoglia il codice sorgente

Prevent scrolling when focusing on input (when Url tab is opened)

Artur Paikin 7 anni fa
parent
commit
179bdf7
2 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  1. 6 1
      src/plugins/Url/UrlUI.js
  2. 0 5
      src/scss/_url.scss

+ 6 - 1
src/plugins/Url/UrlUI.js

@@ -7,7 +7,12 @@ class UrlUI extends Component {
   }
 
   componentDidMount () {
-    this.input.focus()
+    // My guess about why browser scrolls to top on focus:
+    // Component is mounted right away, but the tab panel might be animating
+    // still, so input element is positioned outside viewport. This fixes it.
+    setTimeout(() => {
+      this.input.focus({ preventScroll: true })
+    }, 150)
   }
 
   handleClick () {

+ 0 - 5
src/scss/_url.scss

@@ -25,8 +25,3 @@
   font-size: 16px;
   padding: 12px;
 }
-
-// .uppy-Url-importButton-icon {
-//   width: 100%;
-//   height: 100%;
-// }