@rc-component/portal 2.1.0 → 2.1.2

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.
package/es/Portal.js CHANGED
@@ -54,7 +54,10 @@ const Portal = /*#__PURE__*/React.forwardRef((props, ref) => {
54
54
  const customizeContainer = getPortalContainer(getContainer);
55
55
 
56
56
  // Tell component that we check this in effect which is safe to be `null`
57
- setInnerContainer(customizeContainer ?? null);
57
+ setInnerContainer(() =>
58
+ // React do the state update even the value is the same,
59
+ // Use function call to force React to compare update
60
+ customizeContainer ?? null);
58
61
  });
59
62
  const [defaultContainer, queueCreate] = useDom(mergedRender && !innerContainer, debug);
60
63
  const mergedContainer = innerContainer ?? defaultContainer;
@@ -6,7 +6,7 @@ export let stack = []; // export for testing
6
6
  export default function useEscKeyDown(open, onEsc) {
7
7
  const id = useId();
8
8
  const handleEscKeyDown = useEvent(event => {
9
- if (event.key === 'Escape') {
9
+ if (event.key === 'Escape' && !event.isComposing) {
10
10
  const top = stack[stack.length - 1] === id;
11
11
  onEsc?.({
12
12
  top,
package/lib/Portal.js CHANGED
@@ -63,7 +63,10 @@ const Portal = /*#__PURE__*/React.forwardRef((props, ref) => {
63
63
  const customizeContainer = getPortalContainer(getContainer);
64
64
 
65
65
  // Tell component that we check this in effect which is safe to be `null`
66
- setInnerContainer(customizeContainer ?? null);
66
+ setInnerContainer(() =>
67
+ // React do the state update even the value is the same,
68
+ // Use function call to force React to compare update
69
+ customizeContainer ?? null);
67
70
  });
68
71
  const [defaultContainer, queueCreate] = (0, _useDom.default)(mergedRender && !innerContainer, debug);
69
72
  const mergedContainer = innerContainer ?? defaultContainer;
@@ -14,7 +14,7 @@ let stack = exports.stack = []; // export for testing
14
14
  function useEscKeyDown(open, onEsc) {
15
15
  const id = (0, _useId.default)();
16
16
  const handleEscKeyDown = (0, _util.useEvent)(event => {
17
- if (event.key === 'Escape') {
17
+ if (event.key === 'Escape' && !event.isComposing) {
18
18
  const top = stack[stack.length - 1] === id;
19
19
  onEsc?.({
20
20
  top,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/portal",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "React Portal Component",
5
5
  "keywords": [
6
6
  "react",