From 9d893118d3dd4bc9dc649b278e63e0b858cef4e8 Mon Sep 17 00:00:00 2001 From: kennethormandy Date: Thu, 18 Jun 2020 21:28:41 -0700 Subject: [PATCH 1/4] Adds a failing test case for Safari on iOS --- index.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/index.html b/index.html index 94af9e8..ea0729f 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ + focus-options-polyfill @@ -26,9 +27,21 @@

focus-options-polyfill

+ +
+ + +
+ + +
From e7130e2ccd8e1865a7a0af5ee2fc9e3ae9bd69b3 Mon Sep 17 00:00:00 2001 From: kennethormandy Date: Thu, 18 Jun 2020 21:31:17 -0700 Subject: [PATCH 2/4] Adds fix using setTimeout for Safari on iOS (#17) --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c1bb63e..cb02720 100644 --- a/index.js +++ b/index.js @@ -70,8 +70,14 @@ var patchedFocus = function(args) { if (args && args.preventScroll) { var evScrollableElements = calcScrollableElements(this); - this.nativeFocus(); - restoreScrollPosition(evScrollableElements); + this.nativeFocus() + if (typeof setTimeout === 'function') { + setTimeout(function () { + restoreScrollPosition(evScrollableElements); + }, 100) + } else { + restoreScrollPosition(evScrollableElements); + } } else { this.nativeFocus(); From 37d22d3bee243d371f19c40af37227a83d7c9a7e Mon Sep 17 00:00:00 2001 From: kennethormandy Date: Mon, 22 Jun 2020 09:49:46 -0700 Subject: [PATCH 3/4] Adds missing semicolons --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index cb02720..28e9352 100644 --- a/index.js +++ b/index.js @@ -70,11 +70,11 @@ var patchedFocus = function(args) { if (args && args.preventScroll) { var evScrollableElements = calcScrollableElements(this); - this.nativeFocus() + this.nativeFocus(); if (typeof setTimeout === 'function') { setTimeout(function () { restoreScrollPosition(evScrollableElements); - }, 100) + }, 100); } else { restoreScrollPosition(evScrollableElements); } From 034ede9b654c1f1ada594cab6e0adc7ace8432f7 Mon Sep 17 00:00:00 2001 From: kennethormandy Date: Wed, 24 Jun 2020 17:03:56 -0700 Subject: [PATCH 4/4] Resolves https://github.com/calvellido/focus-options-polyfill/pull/18#pullrequestreview-436549820 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 28e9352..61d4ea4 100644 --- a/index.js +++ b/index.js @@ -74,7 +74,7 @@ if (typeof setTimeout === 'function') { setTimeout(function () { restoreScrollPosition(evScrollableElements); - }, 100); + }, 0); } else { restoreScrollPosition(evScrollableElements); }