@financial-times/n-myft-ui 28.2.5 → 28.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,8 @@ const csrfToken = getToken();
10
10
  let lists = [];
11
11
  let haveLoadedLists = false;
12
12
  let createListOverlay;
13
+ let scrolledOnOpen;
14
+ let listOverlayBottom;
13
15
 
14
16
  export default async function openSaveArticleToListVariant (contentId, options = {}) {
15
17
  const { name, showPublicToggle = false } = options;
@@ -118,6 +120,7 @@ export default async function openSaveArticleToListVariant (contentId, options =
118
120
  }
119
121
 
120
122
  createListOverlay.open();
123
+ scrolledOnOpen = window.scrollY;
121
124
 
122
125
  const scrollHandler = getScrollHandler(createListOverlay.wrapper);
123
126
  const resizeHandler = getResizeHandler(createListOverlay.wrapper);
@@ -130,6 +133,8 @@ export default async function openSaveArticleToListVariant (contentId, options =
130
133
 
131
134
  positionOverlay(data.currentTarget);
132
135
 
136
+ listOverlayBottom = document.querySelector('.myft-ui-create-list-variant').getBoundingClientRect().bottom;
137
+
133
138
  restoreFormHandler();
134
139
 
135
140
  document.querySelector('.article-content').addEventListener('click', outsideClickHandler);
@@ -252,7 +257,6 @@ function FormElement (createList, showPublicToggle, attachDescription, onListCre
252
257
  triggerCreateListEvent(contentId, createdList.uuid);
253
258
  triggerAddToListEvent(contentId, createdList.uuid);
254
259
  positionOverlay(createListOverlay.wrapper);
255
- triggerCancelEvent();
256
260
 
257
261
  if (createdList.isShareable) {
258
262
  createListOverlay.close();
@@ -267,6 +271,7 @@ function FormElement (createList, showPublicToggle, attachDescription, onListCre
267
271
  function handleCancelClick (event) {
268
272
  event.preventDefault();
269
273
  event.stopPropagation();
274
+ triggerCancelEvent();
270
275
  formElement.remove();
271
276
  if (!lists.length) attachDescription();
272
277
  onCancel();
@@ -306,6 +311,7 @@ function ContentElement (hasDescription, onClick) {
306
311
 
307
312
  const contentElement = stringToHTMLElement(content);
308
313
 
314
+ contentElement.querySelector('.myft-ui-create-list-variant-add').addEventListener('click', checkScrollToAdd);
309
315
  contentElement.querySelector('.myft-ui-create-list-variant-add').addEventListener('click', triggerAddToNewListEvent);
310
316
 
311
317
  function removeDescription () {
@@ -590,3 +596,19 @@ function triggerCancelEvent () {
590
596
  bubbles: true
591
597
  }));
592
598
  }
599
+
600
+ //Temporary event to determine whether users need to scroll to add to a list
601
+ function checkScrollToAdd () {
602
+ //if the bottom of the overlay was not showing and scrolling has occurred since it was opened
603
+ if(listOverlayBottom > window.innerHeight && window.scrollY > scrolledOnOpen) {
604
+ document.body.dispatchEvent(new CustomEvent('oTracking.event', {
605
+ detail: {
606
+ category: 'publicToggle',
607
+ action: 'scrollToAdd',
608
+ teamName: 'customer-products-us-growth',
609
+ amplitudeExploratory: true
610
+ },
611
+ bubbles: true
612
+ }));
613
+ }
614
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-myft-ui",
3
- "version": "28.2.5",
3
+ "version": "28.2.7",
4
4
  "description": "Client side component for interaction with myft",
5
5
  "main": "server.js",
6
6
  "scripts": {