@financial-times/n-myft-ui 31.0.0 → 31.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,14 +61,18 @@ const instantAlertsIconOff = ({ event, followPlusInstantAlerts }) => {
61
61
  });
62
62
  };
63
63
 
64
-
65
64
  const sendModalToggleEvent = ({ followPlusInstantAlerts }) => {
66
65
  const preferenceModalToggleEvent = new CustomEvent('myft.preference-modal.show-hide.toggle', { bubbles: true });
67
66
  followPlusInstantAlerts.dispatchEvent(preferenceModalToggleEvent);
68
67
  followPlusInstantAlerts.classList.toggle('n-myft-follow-button--instant-alerts--open');
69
-
70
68
  };
71
69
 
70
+ const sendModalHideEvent = ({ event, followPlusInstantAlerts }) => {
71
+ if (event.target !== followPlusInstantAlerts) {
72
+ const preferenceModalHideEvent = new CustomEvent('myft.preference-modal.hide', { detail: {targetElement: event.target}, bubbles: true });
73
+ followPlusInstantAlerts.dispatchEvent(preferenceModalHideEvent);
74
+ }
75
+ };
72
76
 
73
77
  export default () => {
74
78
  /**
@@ -88,5 +92,8 @@ export default () => {
88
92
  document.body.addEventListener('myft.user.followed.concept.load', (event) => instantAlertsIconLoad({event, followPlusInstantAlerts}));
89
93
 
90
94
  document.body.addEventListener('myft.user.followed.concept.update', (event) => instantAlertsIconUpdate({event, followPlusInstantAlerts}));
95
+
91
96
  document.body.addEventListener('myft.user.followed.concept.remove', (event) => instantAlertsIconOff({ event, followPlusInstantAlerts }));
97
+
98
+ document.addEventListener('click', (event) => sendModalHideEvent({event, followPlusInstantAlerts}));
92
99
  };
@@ -75,6 +75,12 @@ const tracking = (conceptId) => {
75
75
  document.body.dispatchEvent(trackingEvent);
76
76
  };
77
77
 
78
+ const preferenceModalHide = ({ event, preferencesModal }) => {
79
+ if (!preferencesModal.contains(event.detail.targetElement)) {
80
+ preferencesModal.classList.remove('n-myft-ui__preferences-modal--show');
81
+ }
82
+ };
83
+
78
84
  const preferenceModalShowAndHide = ({ event, preferencesModal, conceptId }) => {
79
85
  preferencesModal.classList.toggle('n-myft-ui__preferences-modal--show');
80
86
 
@@ -245,6 +251,8 @@ export default () => {
245
251
 
246
252
  document.addEventListener('myft.preference-modal.show-hide.toggle', event => preferenceModalShowAndHide({ event, preferencesModal, conceptId }));
247
253
 
254
+ document.addEventListener('myft.preference-modal.hide', event => preferenceModalHide({ event, preferencesModal }));
255
+
248
256
  document.addEventListener('myft.user.preferred.preference.load', (event) => getAlertsPreferences({ event, preferencesModal }));
249
257
 
250
258
  document.body.addEventListener('myft.user.followed.concept.load', (event) => setCheckboxForAlertConcept({ event, preferencesModal }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-myft-ui",
3
- "version": "31.0.0",
3
+ "version": "31.0.1",
4
4
  "description": "Client side component for interaction with myft",
5
5
  "main": "server.js",
6
6
  "scripts": {