Skip to content

Commit

Permalink
FIO-9290: fixed an issue where infinite loader is shown when radio/se…
Browse files Browse the repository at this point in the history
…lectboxes with url type is failed to load options
  • Loading branch information
TanyaGashtold committed Nov 1, 2024
1 parent d8f94f4 commit 01a1c3a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/radio/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,13 @@ export default class RadioComponent extends ListComponent {
.then((response) => {
this.loading = false;
this.setItems(response);
this.optionsLoaded = true;
this.redraw();
})
.catch((err) => {
this.optionsLoaded = true;
this.handleLoadingError(err);
})
.finally(() => {
this.optionsLoaded = true;
this.redraw();
});
}

Expand Down
21 changes: 21 additions & 0 deletions test/unit/Radio.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,27 @@ describe('Radio Component', () => {
done();
}).catch(done);
});

it('Should not show infinite loader for radio with URL data source if options loading failed', (done) => {
const form = _.cloneDeep(comp9);
const element = document.createElement('div');
const originalMakeRequest = Formio.makeRequest;

Formio.makeRequest = function() {
return new Promise((res, rej) => {
setTimeout(() => rej('loading error'), 200);
});
};
Formio.createForm(element, form).then(form => {
const radio = form.getComponent('radio');
assert.equal(!!radio.element.querySelector('.loader'), true, 'Should show loader.')
setTimeout(()=>{
assert.equal(!!radio.element.querySelector('.loader'), false, 'Should not show loader.')
Formio.makeRequest = originalMakeRequest;
done();
}, 350);
}).catch(done);
});
});

describe('Radio Component', () => {
Expand Down

0 comments on commit 01a1c3a

Please sign in to comment.