@targetprocess/popover 12.32.4 → 12.32.5-ci.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.
@@ -186,9 +186,13 @@ export class PopoverContainer extends React.Component<
186
186
  }
187
187
 
188
188
  if (this.popoverContentRef.current && !this.props.trapFocus) {
189
- if (!focusFirstDescendant(this.popoverContentRef.current)) {
189
+ // The position computed by adjustPosition() is applied on the next render, so the popover
190
+ // still sits at the top-left corner of its container here. A plain focus() would scroll the
191
+ // container to that corner, so the page jumps away from the trigger.
192
+ const focusOptions = {preventScroll: true}
193
+ if (!focusFirstDescendant(this.popoverContentRef.current, focusOptions)) {
190
194
  this.popoverContentRef.current.tabIndex = -1
191
- this.popoverContentRef.current.focus()
195
+ this.popoverContentRef.current.focus(focusOptions)
192
196
  }
193
197
  }
194
198
  }
@@ -18,6 +18,8 @@ const ComponentWithRef = React.forwardRef<HTMLElement>((prop, ref) => (
18
18
  </div>
19
19
  ))
20
20
 
21
+ const originalFocus = HTMLElement.prototype.focus
22
+
21
23
  describe('Popover', () => {
22
24
  beforeEach(() => {
23
25
  cleanDocumentBody()
@@ -78,4 +80,50 @@ describe('Popover', () => {
78
80
  expect(ref1).toHaveBeenCalled()
79
81
  expect(ref2).toHaveBeenCalled()
80
82
  })
83
+
84
+ describe('without focus trap', () => {
85
+ afterEach(() => {
86
+ HTMLElement.prototype.focus = originalFocus
87
+ })
88
+
89
+ it('should focus container without scrolling when body has no focusable elements', () => {
90
+ const focus = jest.fn(originalFocus)
91
+
92
+ HTMLElement.prototype.focus = focus
93
+
94
+ mount(
95
+ <Popover isOpen trapFocus={false} body={<PopoverBody>foo</PopoverBody>}>
96
+ <button />
97
+ </Popover>
98
+ )
99
+
100
+ expect(document.activeElement).toBe(document.querySelector('[id^="popover-container-"]'))
101
+ expect(focus).toHaveBeenCalledTimes(1)
102
+ expect(focus).toHaveBeenCalledWith({preventScroll: true})
103
+ })
104
+
105
+ it('should focus first focusable element without scrolling', () => {
106
+ const focus = jest.fn(originalFocus)
107
+
108
+ HTMLElement.prototype.focus = focus
109
+
110
+ mount(
111
+ <Popover
112
+ isOpen
113
+ trapFocus={false}
114
+ body={
115
+ <PopoverBody>
116
+ <button className="foo" />
117
+ </PopoverBody>
118
+ }
119
+ >
120
+ <button />
121
+ </Popover>
122
+ )
123
+
124
+ expect(document.activeElement).toBe(document.querySelector('.foo'))
125
+ expect(focus).toHaveBeenCalledTimes(1)
126
+ expect(focus).toHaveBeenCalledWith({preventScroll: true})
127
+ })
128
+ })
81
129
  })
@@ -195,8 +195,8 @@ function styleInject(css, ref) {
195
195
  }
196
196
  }
197
197
 
198
- var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n\n.popover-body-container__popover__12-32-4 {\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n border-radius: var(--BorderRadiusL, 4px);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n background: var(--BackgroundDefault, #FFFFFF);\n z-index: var(--ZIndexModal, 10001);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.popover-body__popover__12-32-4 {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: var(--SpaceSM, 12px);\n font-size: var(--FontSizeDefault, 13px);\n color: var(--FontColorDefault, #000000);\n}\n\n.popover-body--no-padding__popover__12-32-4 {\n padding: 0;\n }\n\n.popover-tip__popover__12-32-4 {\n position: absolute;\n pointer-events: none;\n z-index: calc(1 + var(--ZIndexModal, 10001));\n overflow: hidden;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n\n /*\n To determine tip position, we need to rotate it\n along the \"tip\" point, after that, the \"tip\" point\n can be placed with exactly 50% offset from the origin\n so that it is centered.\n */\n}\n\n.popover-tip__popover__12-32-4:before {\n content: '';\n position: absolute;\n display: block;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n background-color: var(--BackgroundDefault, #FFFFFF);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n /*\n geometry FTW\n\n 2*$popoverTipSize\n _______ _______\n | /|\\ |\n | / | \\ | $popoverTipSize\n | / | \\ |\n |/______|______\\|\n since tip is rotated 45 degrees, its width and height is a\n diagonal of a square with side=$popoverTipSize, thus diagonal\n is sqrt(2) * $popoverTipSize.\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\n */\n width: calc(11.2px);\n height: calc(11.2px);\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n\n.popover-tip--bottom__popover__12-32-4,\n .popover-tip--top__popover__12-32-4 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: calc(9px);\n }\n\n.popover-tip--left__popover__12-32-4,\n .popover-tip--right__popover__12-32-4 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: calc(9px);\n }\n\n.popover-tip--bottom__popover__12-32-4:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n\n.popover-tip--top__popover__12-32-4:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n\n.popover-tip--left__popover__12-32-4:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n\n.popover-tip--right__popover__12-32-4:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
199
- var styles = {"popover-body-container":"popover-body-container__popover__12-32-4","popover-body":"popover-body__popover__12-32-4","popover-body--no-padding":"popover-body--no-padding__popover__12-32-4","popover-tip":"popover-tip__popover__12-32-4","popover-tip--bottom":"popover-tip--bottom__popover__12-32-4","popover-tip--top":"popover-tip--top__popover__12-32-4","popover-tip--left":"popover-tip--left__popover__12-32-4","popover-tip--right":"popover-tip--right__popover__12-32-4"};
198
+ var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n\n.popover-body-container__popover__12-32-5-ci-2 {\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n border-radius: var(--BorderRadiusL, 4px);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n background: var(--BackgroundDefault, #FFFFFF);\n z-index: var(--ZIndexModal, 10001);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.popover-body__popover__12-32-5-ci-2 {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: var(--SpaceSM, 12px);\n font-size: var(--FontSizeDefault, 13px);\n color: var(--FontColorDefault, #000000);\n}\n\n.popover-body--no-padding__popover__12-32-5-ci-2 {\n padding: 0;\n }\n\n.popover-tip__popover__12-32-5-ci-2 {\n position: absolute;\n pointer-events: none;\n z-index: calc(1 + var(--ZIndexModal, 10001));\n overflow: hidden;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n\n /*\n To determine tip position, we need to rotate it\n along the \"tip\" point, after that, the \"tip\" point\n can be placed with exactly 50% offset from the origin\n so that it is centered.\n */\n}\n\n.popover-tip__popover__12-32-5-ci-2:before {\n content: '';\n position: absolute;\n display: block;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n background-color: var(--BackgroundDefault, #FFFFFF);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n /*\n geometry FTW\n\n 2*$popoverTipSize\n _______ _______\n | /|\\ |\n | / | \\ | $popoverTipSize\n | / | \\ |\n |/______|______\\|\n since tip is rotated 45 degrees, its width and height is a\n diagonal of a square with side=$popoverTipSize, thus diagonal\n is sqrt(2) * $popoverTipSize.\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\n */\n width: calc(11.2px);\n height: calc(11.2px);\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n\n.popover-tip--bottom__popover__12-32-5-ci-2,\n .popover-tip--top__popover__12-32-5-ci-2 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: calc(9px);\n }\n\n.popover-tip--left__popover__12-32-5-ci-2,\n .popover-tip--right__popover__12-32-5-ci-2 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: calc(9px);\n }\n\n.popover-tip--bottom__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n\n.popover-tip--top__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n\n.popover-tip--left__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n\n.popover-tip--right__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
199
+ var styles = {"popover-body-container":"popover-body-container__popover__12-32-5-ci-2","popover-body":"popover-body__popover__12-32-5-ci-2","popover-body--no-padding":"popover-body--no-padding__popover__12-32-5-ci-2","popover-tip":"popover-tip__popover__12-32-5-ci-2","popover-tip--bottom":"popover-tip--bottom__popover__12-32-5-ci-2","popover-tip--top":"popover-tip--top__popover__12-32-5-ci-2","popover-tip--left":"popover-tip--left__popover__12-32-5-ci-2","popover-tip--right":"popover-tip--right__popover__12-32-5-ci-2"};
200
200
  styleInject(css_248z);
201
201
 
202
202
  /*********************************************************************
@@ -268,17 +268,17 @@ var isFocusable = function isFocusable(element) {
268
268
  return false;
269
269
  }
270
270
  };
271
- var attemptFocus = function attemptFocus(element) {
271
+ var attemptFocus = function attemptFocus(element, options) {
272
272
  if (!isFocusable(element)) {
273
273
  return false;
274
274
  }
275
- element.focus();
275
+ element.focus(options);
276
276
  return document.activeElement === element;
277
277
  };
278
- var _focusFirstDescendant = function focusFirstDescendant(element) {
278
+ var _focusFirstDescendant = function focusFirstDescendant(element, options) {
279
279
  for (var _i = 0, _Array$from = Array.from(element.childNodes); _i < _Array$from.length; _i++) {
280
280
  var child = _Array$from[_i];
281
- if (attemptFocus(child) || _focusFirstDescendant(child)) {
281
+ if (attemptFocus(child, options) || _focusFirstDescendant(child, options)) {
282
282
  return true;
283
283
  }
284
284
  }
@@ -423,9 +423,15 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
423
423
  }
424
424
  }
425
425
  if (this.popoverContentRef.current && !this.props.trapFocus) {
426
- if (!_focusFirstDescendant(this.popoverContentRef.current)) {
426
+ // The position computed by adjustPosition() is applied on the next render, so the popover
427
+ // still sits at the top-left corner of its container here. A plain focus() would scroll the
428
+ // container to that corner, so the page jumps away from the trigger.
429
+ var focusOptions = {
430
+ preventScroll: true
431
+ };
432
+ if (!_focusFirstDescendant(this.popoverContentRef.current, focusOptions)) {
427
433
  this.popoverContentRef.current.tabIndex = -1;
428
- this.popoverContentRef.current.focus();
434
+ this.popoverContentRef.current.focus(focusOptions);
429
435
  }
430
436
  }
431
437
  }
package/dist/popover.js CHANGED
@@ -206,8 +206,8 @@ function styleInject(css, ref) {
206
206
  }
207
207
  }
208
208
 
209
- var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n\n.popover-body-container__popover__12-32-4 {\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n border-radius: var(--BorderRadiusL, 4px);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n background: var(--BackgroundDefault, #FFFFFF);\n z-index: var(--ZIndexModal, 10001);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.popover-body__popover__12-32-4 {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: var(--SpaceSM, 12px);\n font-size: var(--FontSizeDefault, 13px);\n color: var(--FontColorDefault, #000000);\n}\n\n.popover-body--no-padding__popover__12-32-4 {\n padding: 0;\n }\n\n.popover-tip__popover__12-32-4 {\n position: absolute;\n pointer-events: none;\n z-index: calc(1 + var(--ZIndexModal, 10001));\n overflow: hidden;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n\n /*\n To determine tip position, we need to rotate it\n along the \"tip\" point, after that, the \"tip\" point\n can be placed with exactly 50% offset from the origin\n so that it is centered.\n */\n}\n\n.popover-tip__popover__12-32-4:before {\n content: '';\n position: absolute;\n display: block;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n background-color: var(--BackgroundDefault, #FFFFFF);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n /*\n geometry FTW\n\n 2*$popoverTipSize\n _______ _______\n | /|\\ |\n | / | \\ | $popoverTipSize\n | / | \\ |\n |/______|______\\|\n since tip is rotated 45 degrees, its width and height is a\n diagonal of a square with side=$popoverTipSize, thus diagonal\n is sqrt(2) * $popoverTipSize.\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\n */\n width: calc(11.2px);\n height: calc(11.2px);\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n\n.popover-tip--bottom__popover__12-32-4,\n .popover-tip--top__popover__12-32-4 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: calc(9px);\n }\n\n.popover-tip--left__popover__12-32-4,\n .popover-tip--right__popover__12-32-4 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: calc(9px);\n }\n\n.popover-tip--bottom__popover__12-32-4:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n\n.popover-tip--top__popover__12-32-4:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n\n.popover-tip--left__popover__12-32-4:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n\n.popover-tip--right__popover__12-32-4:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
210
- var styles = {"popover-body-container":"popover-body-container__popover__12-32-4","popover-body":"popover-body__popover__12-32-4","popover-body--no-padding":"popover-body--no-padding__popover__12-32-4","popover-tip":"popover-tip__popover__12-32-4","popover-tip--bottom":"popover-tip--bottom__popover__12-32-4","popover-tip--top":"popover-tip--top__popover__12-32-4","popover-tip--left":"popover-tip--left__popover__12-32-4","popover-tip--right":"popover-tip--right__popover__12-32-4"};
209
+ var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n\n.popover-body-container__popover__12-32-5-ci-2 {\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n border-radius: var(--BorderRadiusL, 4px);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n background: var(--BackgroundDefault, #FFFFFF);\n z-index: var(--ZIndexModal, 10001);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.popover-body__popover__12-32-5-ci-2 {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: var(--SpaceSM, 12px);\n font-size: var(--FontSizeDefault, 13px);\n color: var(--FontColorDefault, #000000);\n}\n\n.popover-body--no-padding__popover__12-32-5-ci-2 {\n padding: 0;\n }\n\n.popover-tip__popover__12-32-5-ci-2 {\n position: absolute;\n pointer-events: none;\n z-index: calc(1 + var(--ZIndexModal, 10001));\n overflow: hidden;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n\n /*\n To determine tip position, we need to rotate it\n along the \"tip\" point, after that, the \"tip\" point\n can be placed with exactly 50% offset from the origin\n so that it is centered.\n */\n}\n\n.popover-tip__popover__12-32-5-ci-2:before {\n content: '';\n position: absolute;\n display: block;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n background-color: var(--BackgroundDefault, #FFFFFF);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n /*\n geometry FTW\n\n 2*$popoverTipSize\n _______ _______\n | /|\\ |\n | / | \\ | $popoverTipSize\n | / | \\ |\n |/______|______\\|\n since tip is rotated 45 degrees, its width and height is a\n diagonal of a square with side=$popoverTipSize, thus diagonal\n is sqrt(2) * $popoverTipSize.\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\n */\n width: calc(11.2px);\n height: calc(11.2px);\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n\n.popover-tip--bottom__popover__12-32-5-ci-2,\n .popover-tip--top__popover__12-32-5-ci-2 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: calc(9px);\n }\n\n.popover-tip--left__popover__12-32-5-ci-2,\n .popover-tip--right__popover__12-32-5-ci-2 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: calc(9px);\n }\n\n.popover-tip--bottom__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n\n.popover-tip--top__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n\n.popover-tip--left__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n\n.popover-tip--right__popover__12-32-5-ci-2:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
210
+ var styles = {"popover-body-container":"popover-body-container__popover__12-32-5-ci-2","popover-body":"popover-body__popover__12-32-5-ci-2","popover-body--no-padding":"popover-body--no-padding__popover__12-32-5-ci-2","popover-tip":"popover-tip__popover__12-32-5-ci-2","popover-tip--bottom":"popover-tip--bottom__popover__12-32-5-ci-2","popover-tip--top":"popover-tip--top__popover__12-32-5-ci-2","popover-tip--left":"popover-tip--left__popover__12-32-5-ci-2","popover-tip--right":"popover-tip--right__popover__12-32-5-ci-2"};
211
211
  styleInject(css_248z);
212
212
 
213
213
  /*********************************************************************
@@ -279,17 +279,17 @@ var isFocusable = function isFocusable(element) {
279
279
  return false;
280
280
  }
281
281
  };
282
- var attemptFocus = function attemptFocus(element) {
282
+ var attemptFocus = function attemptFocus(element, options) {
283
283
  if (!isFocusable(element)) {
284
284
  return false;
285
285
  }
286
- element.focus();
286
+ element.focus(options);
287
287
  return document.activeElement === element;
288
288
  };
289
- var _focusFirstDescendant = function focusFirstDescendant(element) {
289
+ var _focusFirstDescendant = function focusFirstDescendant(element, options) {
290
290
  for (var _i = 0, _Array$from = Array.from(element.childNodes); _i < _Array$from.length; _i++) {
291
291
  var child = _Array$from[_i];
292
- if (attemptFocus(child) || _focusFirstDescendant(child)) {
292
+ if (attemptFocus(child, options) || _focusFirstDescendant(child, options)) {
293
293
  return true;
294
294
  }
295
295
  }
@@ -434,9 +434,15 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
434
434
  }
435
435
  }
436
436
  if (this.popoverContentRef.current && !this.props.trapFocus) {
437
- if (!_focusFirstDescendant(this.popoverContentRef.current)) {
437
+ // The position computed by adjustPosition() is applied on the next render, so the popover
438
+ // still sits at the top-left corner of its container here. A plain focus() would scroll the
439
+ // container to that corner, so the page jumps away from the trigger.
440
+ var focusOptions = {
441
+ preventScroll: true
442
+ };
443
+ if (!_focusFirstDescendant(this.popoverContentRef.current, focusOptions)) {
438
444
  this.popoverContentRef.current.tabIndex = -1;
439
- this.popoverContentRef.current.focus();
445
+ this.popoverContentRef.current.focus(focusOptions);
440
446
  }
441
447
  }
442
448
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@targetprocess/popover",
3
- "version": "12.32.4",
3
+ "version": "12.32.5-ci.2",
4
4
  "description": "",
5
5
  "main": "dist/popover.js",
6
6
  "module": "dist/popover.es.js",
@@ -22,5 +22,5 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "gitHead": "0f3bea6efea9ac18fb387927d16e46efbb266acb"
25
+ "gitHead": "56b126be3263f90df6d7efeed855d56329cd007b"
26
26
  }