From 8fd7ccf121ab391f021c9e6eec97d98f46fc0079 Mon Sep 17 00:00:00 2001 From: Matt Bevilacqua Date: Thu, 3 Jun 2021 15:46:29 -0400 Subject: [PATCH 1/4] add matches polyfill --- frontend/src/App.js | 2 ++ frontend/src/pages/Landing/Filter.js | 1 + frontend/src/polyfills.js | 4 ++++ 3 files changed, 7 insertions(+) create mode 100644 frontend/src/polyfills.js diff --git a/frontend/src/App.js b/frontend/src/App.js index 390ad13868..f402d0a972 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -28,6 +28,8 @@ import RequestPermissions from './components/RequestPermissions'; import AriaLiveContext from './AriaLiveContext'; import AriaLiveRegion from './components/AriaLiveRegion'; +import './polyfills'; + function App() { const [user, updateUser] = useState(); const [authError, updateAuthError] = useState(); diff --git a/frontend/src/pages/Landing/Filter.js b/frontend/src/pages/Landing/Filter.js index d1ec1d8ac9..957041858c 100644 --- a/frontend/src/pages/Landing/Filter.js +++ b/frontend/src/pages/Landing/Filter.js @@ -76,6 +76,7 @@ function Filter({ applyFilters, forMyAlerts }) { // https://reactjs.org/docs/events.html#detecting-focus-entering-and-leaving // e.relatedTarget can be null when focus changes within the menu (when using VoiceOver) + // const isCalendarControl = e.target.classList.contains('CalendarDay') || e.target.classList.contains('DayPickerNavigation_button'); const isCalendarControl = e.target.matches('.CalendarDay, .DayPickerNavigation_button'); if (!isCalendarControl && !e.currentTarget.contains(e.relatedTarget)) { diff --git a/frontend/src/polyfills.js b/frontend/src/polyfills.js new file mode 100644 index 0000000000..3d0cadfe02 --- /dev/null +++ b/frontend/src/polyfills.js @@ -0,0 +1,4 @@ +if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.msMatchesSelector + || Element.prototype.webkitMatchesSelector; +} From 402f8f203a3e31f8bf2383d839d9128cb04d4cf0 Mon Sep 17 00:00:00 2001 From: Matt Bevilacqua Date: Thu, 3 Jun 2021 16:04:58 -0400 Subject: [PATCH 2/4] bump polyfill up a level --- frontend/src/App.js | 2 -- frontend/src/index.js | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/App.js b/frontend/src/App.js index f402d0a972..390ad13868 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -28,8 +28,6 @@ import RequestPermissions from './components/RequestPermissions'; import AriaLiveContext from './AriaLiveContext'; import AriaLiveRegion from './components/AriaLiveRegion'; -import './polyfills'; - function App() { const [user, updateUser] = useState(); const [authError, updateAuthError] = useState(); diff --git a/frontend/src/index.js b/frontend/src/index.js index 55ed3a1205..ecbb3f53d6 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -1,5 +1,6 @@ import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable'; +import './polyfills'; import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; From 2528f292036d3cb30b7f6a38d75561188cb224f9 Mon Sep 17 00:00:00 2001 From: Matt Bevilacqua Date: Fri, 4 Jun 2021 08:01:58 -0400 Subject: [PATCH 3/4] removed bad comment and added good one --- frontend/src/pages/Landing/Filter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/Landing/Filter.js b/frontend/src/pages/Landing/Filter.js index 957041858c..d525f6b609 100644 --- a/frontend/src/pages/Landing/Filter.js +++ b/frontend/src/pages/Landing/Filter.js @@ -76,7 +76,10 @@ function Filter({ applyFilters, forMyAlerts }) { // https://reactjs.org/docs/events.html#detecting-focus-entering-and-leaving // e.relatedTarget can be null when focus changes within the menu (when using VoiceOver) - // const isCalendarControl = e.target.classList.contains('CalendarDay') || e.target.classList.contains('DayPickerNavigation_button'); + /** + * We check for these because if we don't, the filter menu will abruptly close when the calendar day + * or the month navigation buttons are clicked, rendering the date picker un-usable + */ const isCalendarControl = e.target.matches('.CalendarDay, .DayPickerNavigation_button'); if (!isCalendarControl && !e.currentTarget.contains(e.relatedTarget)) { From 42b7aa099c763af79b22240ba87db5f39fb0d098 Mon Sep 17 00:00:00 2001 From: Matt Bevilacqua Date: Fri, 4 Jun 2021 08:17:53 -0400 Subject: [PATCH 4/4] exclude polyfills from test coverage --- frontend/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/package.json b/frontend/package.json index 6ecb7057a2..466e51668d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -149,7 +149,8 @@ "coveragePathIgnorePatterns": [ "/src/index.js", "/src/setupProxy.js", - "/src/pages/NotFound/index.js" + "/src/pages/NotFound/index.js", + "/src/polyfills.js" ], "coverageThreshold": { "global": {