Skip to content

Commit b810bda

Browse files
AnurudraSShivam Agarwal
authored andcommitted
FORMS-9362: loading icon behind fields (#880)
* FORMS-9362: loading icon behind fields * FORMS-9362 : null check added as per comments * FORMS-9362 : changes due to review comments * FORMS-9362 : formatting the changes
1 parent 54f671a commit b810bda

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ BLOCK cmp-adaptiveform-container
6666
## JavaScript Data Attribute Bindings
6767

6868
Apply a `data-cmp-is="adaptiveFormContainer"` attribute to the `cmp-adaptiveform-container` block to enable initialization of the JavaScript component.
69+
70+
Applying `data-cmp-adaptiveform-container-loader` attribute to the div specifically for applying the loader class on it, it is to ensure that the loading icon should not appear over components.

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/site/js/formcontainerview.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,20 @@
6363
const startTime = new Date().getTime();
6464
let elements = document.querySelectorAll(FormContainerV2.selectors.self);
6565
for (let i = 0; i < elements.length; i++) {
66-
elements[i].classList.add(FormContainerV2.loadingClass);
66+
let loaderToAdd = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ elements[i].id + "']");
67+
if(loaderToAdd){
68+
loaderToAdd.classList.add(FormContainerV2.loadingClass);
69+
}
6770
console.debug("Form loading started", elements[i].id);
6871
}
6972
function onInit(e) {
7073
let formContainer = e.detail;
7174
let formEl = formContainer.getFormElement();
7275
setTimeout(() => {
73-
formEl.classList.remove(FormContainerV2.loadingClass);
76+
let loaderToRemove = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ formEl.id + "']");
77+
if(loaderToRemove){
78+
loaderToRemove.classList.remove(FormContainerV2.loadingClass);
79+
}
7480
const timeTaken = new Date().getTime() - startTime;
7581
console.debug("Form loading complete", formEl.id, timeTaken);
7682
}, 10);

ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/container.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
<sly data-sly-use="${'removeattribute.js' @ referencedPage }"/>
4343
</div>
4444
</form>
45-
45+
<div data-cmp-adaptiveform-container-loader="${container.id}"></div>

ui.tests/test-module/libs/support/commands.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,20 @@ const waitForFormInit = () => {
338338
cy.get('form').then(($form) => {
339339
const promise = new Cypress.Promise((resolve, reject) => {
340340
const listener1 = e => {
341+
if(document.querySelector("[data-cmp-adaptiveform-container-loader='"+ $form[0].id + "']").classList.contains("cmp-adaptiveform-container--loading")){
341342
const isReady = () => {
342-
if (!($form[0].classList.contains("cmp-adaptiveform-container--loading"))) {
343+
const container = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ $form[0].id + "']");
344+
if (container &&
345+
e.detail._path === $form.data("cmp-path") &&
346+
!container.classList.contains("cmp-adaptiveform-container--loading")) {
347+
343348
resolve(e.detail);
344349
}
345350
setTimeout(isReady, 0)
346351
}
347352
isReady();
348353
}
354+
}
349355
document.addEventListener(INIT_EVENT, listener1);
350356
})
351357
return promise
@@ -360,15 +366,20 @@ const waitForFormInitMultipleContiners = () => {
360366
cy.get('form').each(($form) => {
361367
const promise = new Cypress.Promise((resolve, reject) => {
362368
const listener1 = e => {
369+
if(document.querySelector("[data-cmp-adaptiveform-container-loader='"+ $form[0].id + "']").classList.contains("cmp-adaptiveform-container--loading")){
363370
const isReady = () => {
364-
if (e.detail._path === $form.data("cmp-path") &&
365-
!($form[0].classList.contains("cmp-adaptiveform-container--loading"))) {
371+
const container = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ $form[0].id + "']");
372+
if (container &&
373+
e.detail._path === $form.data("cmp-path") &&
374+
!container.classList.contains("cmp-adaptiveform-container--loading")) {
375+
366376
resolve(e.detail);
367377
}
368378
setTimeout(isReady, 0)
369379
}
370380
isReady();
371381
}
382+
}
372383
document.addEventListener(INIT_EVENT, listener1);
373384
})
374385

0 commit comments

Comments
 (0)