@workday/canvas-kit-react 8.4.7 → 8.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"useReturnFocus.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useReturnFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAiC1B;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;OAgGzB,CAAC"}
1
+ {"version":3,"file":"useReturnFocus.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useReturnFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAiC1B;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;OA6GzB,CAAC"}
@@ -104,7 +104,11 @@ exports.useReturnFocus = common_1.createElemPropsHook(usePopupModel_1.usePopupMo
104
104
  elementRef.current = null;
105
105
  return;
106
106
  }
107
- if (requiresFocusChangeRef.current) {
107
+ var activeElementOutsidePopupStack = document.activeElement !== document.body &&
108
+ model.state.stackRef.current &&
109
+ document.activeElement instanceof HTMLElement &&
110
+ !canvas_kit_popup_stack_1.PopupStack.contains(model.state.stackRef.current, document.activeElement);
111
+ if (activeElementOutsidePopupStack || requiresFocusChangeRef.current) {
108
112
  // We need to change focus _before_ the browser process the default action of picking a new
109
113
  // focus target. Doing this immediately prevents the `focus` event from firing on `element`,
110
114
  // but that's okay because the browser will change focus anyways.
@@ -119,6 +123,13 @@ exports.useReturnFocus = common_1.createElemPropsHook(usePopupModel_1.usePopupMo
119
123
  }
120
124
  elementRef.current = null;
121
125
  };
122
- }, [model.state.returnFocusRef, model.state.targetRef, visible, onMouseDown, onKeyDown]);
126
+ }, [
127
+ model.state.returnFocusRef,
128
+ model.state.targetRef,
129
+ visible,
130
+ onMouseDown,
131
+ onKeyDown,
132
+ model.state.stackRef,
133
+ ]);
123
134
  return {};
124
135
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useReturnFocus.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useReturnFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAiC1B;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;OAgGzB,CAAC"}
1
+ {"version":3,"file":"useReturnFocus.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useReturnFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAiC1B;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;OA6GzB,CAAC"}
@@ -98,7 +98,11 @@ export var useReturnFocus = createElemPropsHook(usePopupModel)(function (model)
98
98
  elementRef.current = null;
99
99
  return;
100
100
  }
101
- if (requiresFocusChangeRef.current) {
101
+ var activeElementOutsidePopupStack = document.activeElement !== document.body &&
102
+ model.state.stackRef.current &&
103
+ document.activeElement instanceof HTMLElement &&
104
+ !PopupStack.contains(model.state.stackRef.current, document.activeElement);
105
+ if (activeElementOutsidePopupStack || requiresFocusChangeRef.current) {
102
106
  // We need to change focus _before_ the browser process the default action of picking a new
103
107
  // focus target. Doing this immediately prevents the `focus` event from firing on `element`,
104
108
  // but that's okay because the browser will change focus anyways.
@@ -113,6 +117,13 @@ export var useReturnFocus = createElemPropsHook(usePopupModel)(function (model)
113
117
  }
114
118
  elementRef.current = null;
115
119
  };
116
- }, [model.state.returnFocusRef, model.state.targetRef, visible, onMouseDown, onKeyDown]);
120
+ }, [
121
+ model.state.returnFocusRef,
122
+ model.state.targetRef,
123
+ visible,
124
+ onMouseDown,
125
+ onKeyDown,
126
+ model.state.stackRef,
127
+ ]);
117
128
  return {};
118
129
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "8.4.7",
3
+ "version": "8.4.9",
4
4
  "description": "The parent module that contains all Workday Canvas Kit React components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  "@emotion/styled": "^11.6.0",
50
50
  "@popperjs/core": "^2.5.4",
51
51
  "@workday/canvas-colors-web": "^2.0.0",
52
- "@workday/canvas-kit-popup-stack": "^8.4.7",
52
+ "@workday/canvas-kit-popup-stack": "^8.4.9",
53
53
  "@workday/canvas-system-icons-web": "^3.0.0",
54
54
  "@workday/design-assets-types": "^0.2.8",
55
55
  "chroma-js": "^2.1.0",
@@ -67,5 +67,5 @@
67
67
  "@workday/canvas-accent-icons-web": "^3.0.0",
68
68
  "@workday/canvas-applet-icons-web": "^2.0.0"
69
69
  },
70
- "gitHead": "f60d81f57ac03edebfcea6337277780ebecd416a"
70
+ "gitHead": "2afa0a6e3c1bae0b94a209ed3ad9c07db25edbbf"
71
71
  }
@@ -116,7 +116,13 @@ export const useReturnFocus = createElemPropsHook(usePopupModel)(model => {
116
116
  return;
117
117
  }
118
118
 
119
- if (requiresFocusChangeRef.current) {
119
+ const activeElementOutsidePopupStack =
120
+ document.activeElement !== document.body &&
121
+ model.state.stackRef.current &&
122
+ document.activeElement instanceof HTMLElement &&
123
+ !PopupStack.contains(model.state.stackRef.current, document.activeElement);
124
+
125
+ if (activeElementOutsidePopupStack || requiresFocusChangeRef.current) {
120
126
  // We need to change focus _before_ the browser process the default action of picking a new
121
127
  // focus target. Doing this immediately prevents the `focus` event from firing on `element`,
122
128
  // but that's okay because the browser will change focus anyways.
@@ -131,7 +137,14 @@ export const useReturnFocus = createElemPropsHook(usePopupModel)(model => {
131
137
 
132
138
  elementRef.current = null;
133
139
  };
134
- }, [model.state.returnFocusRef, model.state.targetRef, visible, onMouseDown, onKeyDown]);
140
+ }, [
141
+ model.state.returnFocusRef,
142
+ model.state.targetRef,
143
+ visible,
144
+ onMouseDown,
145
+ onKeyDown,
146
+ model.state.stackRef,
147
+ ]);
135
148
 
136
149
  return {};
137
150
  });