Skip to content

Commit

Permalink
moved focus logic to RD2 _EnablementDelegateHelper.js
Browse files Browse the repository at this point in the history
added he 'setFocus' method in RD2 _EnablementDelegateHelper.js and invoked it from RD2_EnablementDelegateController.js.
  • Loading branch information
salesforce-suyash-more committed Jul 2, 2024
1 parent b8dbc59 commit dde36c5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@
helper.handleBatchEvent(component, event, 'v.dryRunBatch');
helper.refreshDryRun(component);
helper.refreshEnable(component);
window.setTimeout(function() {
var dryRunJob = component.find("dryRun2Job");
if (event.Hp.batchProgress.status === "Completed") {
dryRunJob.getElement().setAttribute('tabindex', '0');
dryRunJob.getElement().focus();
var status = event.Hp.batchProgress.status;
var dryRunJob = component.find("dryRunJob");
if (["Completed", "Aborted"].includes(status)) {
if(dryRunJob){
helper.setFocus(component, 'dryRunJob');
}
}, 0);
else{
helper.setFocus(component, 'dryRun2Job');
}
}
},
handleDryRunError: function (component, event, helper) {
helper.handleBatchError(component, event, 'dryRun');
Expand All @@ -51,13 +54,10 @@
handleMigrationStatusChange: function (component, event, helper) {
helper.handleBatchEvent(component, event, 'v.migrationBatch');
helper.refreshMigration(component);
window.setTimeout(function() {
var migrationJob = component.find("migrationJob");
if (event.Hp.batchProgress.status === "Completed") {
migrationJob.getElement().setAttribute('tabindex', '0');
migrationJob.getElement().focus();
var status = event.Hp.batchProgress.status;
if (["Completed", "Aborted"].includes(status)) {
helper.setFocus(component, 'migrationJob');
}
}, 0);
},
handleMigrationError: function (component, event, helper) {
helper.handleBatchError(component, event, 'migration');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,5 +599,22 @@
hideSpinner: function (component, element) {
var spinner = component.find(element);
$A.util.addClass(spinner, 'slds-hide');
}
},
/**
* @description: Autofocus
*/
setFocus: function (component, elementId) {
window.setTimeout(() => {
try { var element = component.find(elementId);
if (element) {
element.getElement().setAttribute('tabindex', '0');
element.getElement().focus();
element.getElement().setAttribute('tabindex', '-1');
}
} catch (error) {
console.error('Error setting focus on element:', error);

}
}, 0);
}
})

0 comments on commit dde36c5

Please sign in to comment.