Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-9290: fixed an issue where infinite loader is shown when radio/selectboxes with url type is failed to load options #5891

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading