You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/module/patternfly-docs/content/extensions/component-groups/examples/FieldBuilder/FieldBuilderExample.tsx
Copy file name to clipboardExpand all lines: packages/module/patternfly-docs/content/extensions/component-groups/examples/FieldBuilder/FieldBuilderSelectExample.tsx
// Focus management: avoid focusing on destructive actions
44
+
setTimeout(()=>{
45
+
// If there are still team members after removal
46
+
if(newTeamMembers.length>0){
47
+
// If we removed the last row, focus the new last row's first select
48
+
if(index>=newTeamMembers.length){
49
+
constnewLastRowIndex=newTeamMembers.length;
50
+
constpreviousRowFirstSelect=document.querySelector(`select[aria-label*="Team member ${newLastRowIndex}"][aria-label*="Department"]`)asHTMLSelectElement;
51
+
if(previousRowFirstSelect){
52
+
previousRowFirstSelect.focus();
53
+
}
54
+
}else{
55
+
// If we removed a middle row, focus the first select of the row that took its place
56
+
constnewRowNumber=index+1;
57
+
constsameIndexFirstSelect=document.querySelector(`select[aria-label*="Team member ${newRowNumber}"][aria-label*="Department"]`)asHTMLSelectElement;
58
+
if(sameIndexFirstSelect){
59
+
sameIndexFirstSelect.focus();
60
+
}
61
+
}
62
+
}else{
63
+
// If this was the last team member, focus the add button
0 commit comments