@brightspace-ui/core 3.56.0 → 3.57.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -101,3 +101,4 @@ pager.addEventListener('d2l-pager-load-more', e => {
101
101
  | Event | Description |
102
102
  |---|---|
103
103
  | `d2l-pager-load-more` | Dispatched when the user clicks the Load More button. The `pageSize` can be accessed from the event `target`. The consumer must call the `complete()` method on the event detail to signal completion after the new items have been loaded. |
104
+ | `d2l-pager-load-more-loaded` | Dispatched after more items have been loaded.
@@ -17,6 +17,7 @@ const nativeFocus = document.createElement('div').focus;
17
17
  /**
18
18
  * A pager component for load-more paging.
19
19
  * @fires d2l-pager-load-more - Dispatched when the user clicks the load-more button. Consumers must call the provided "complete" method once items have been loaded.
20
+ * @fires d2l-pager-load-more-loaded - Dispatched after more items have been loaded.
20
21
  */
21
22
  class LoadMore extends PageableSubscriberMixin(FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))) {
22
23
 
@@ -125,24 +126,34 @@ class LoadMore extends PageableSubscriberMixin(FocusMixin(LocalizeCoreElement(Rt
125
126
  this._loading = false;
126
127
 
127
128
  // wait a frame for async sub-components to render
128
- await new Promise(resolve => requestAnimationFrame(resolve));
129
+ await new Promise(requestAnimationFrame);
129
130
 
130
131
  const item = pageable._getItemByIndex(lastItemIndex + 1);
131
132
 
132
- if (!item) return;
133
- if (item.updateComplete) await item.updateComplete;
134
-
135
- if (item.focus !== nativeFocus) {
136
- requestAnimationFrame(() => item.focus());
137
- } else {
138
- const firstFocusable = getFirstFocusableDescendant(item);
139
- if (firstFocusable) {
140
- firstFocusable.focus();
141
- } else if (item.focus === nativeFocus) {
142
- item.tabIndex = -1;
143
- requestAnimationFrame(() => item.focus());
133
+ let itemToFocus;
134
+ if (item) {
135
+ if (item.updateComplete) await item.updateComplete;
136
+ if (item.focus !== nativeFocus) {
137
+ itemToFocus = item;
138
+ } else {
139
+ const firstFocusable = getFirstFocusableDescendant(item);
140
+ if (firstFocusable) {
141
+ itemToFocus = firstFocusable;
142
+ } else if (item.focus === nativeFocus) {
143
+ item.tabIndex = -1;
144
+ itemToFocus = item;
145
+ }
144
146
  }
145
147
  }
148
+
149
+ if (itemToFocus) {
150
+ await new Promise(requestAnimationFrame);
151
+ itemToFocus.focus();
152
+ }
153
+
154
+ await new Promise(requestAnimationFrame);
155
+ this.dispatchEvent(new CustomEvent('d2l-pager-load-more-loaded'));
156
+
146
157
  }
147
158
 
148
159
  }
@@ -10535,6 +10535,10 @@
10535
10535
  {
10536
10536
  "name": "d2l-pager-load-more",
10537
10537
  "description": "Dispatched when the user clicks the load-more button. Consumers must call the provided \"complete\" method once items have been loaded."
10538
+ },
10539
+ {
10540
+ "name": "d2l-pager-load-more-loaded",
10541
+ "description": "Dispatched after more items have been loaded."
10538
10542
  }
10539
10543
  ]
10540
10544
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.56.0",
3
+ "version": "3.57.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",