Skip to content

Commit 932f35f

Browse files
authored
Dropdown, RichTooltip - fix ResizeObserver-related errors (#2550)
1 parent 0ed679c commit 932f35f

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

.changeset/great-papayas-develop.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@hashicorp/design-system-components": patch
3+
---
4+
5+
`Dropdown`, `RichTooltip` - Fixed `ResizeObserver`-related errors in tests
6+
7+
Upgraded `@floating-ui/dom` to `1.6.12`

packages/components/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@ember/string": "^3.1.1",
4040
"@ember/test-waiters": "^3.1.0",
4141
"@embroider/addon-shim": "^1.8.7",
42-
"@floating-ui/dom": "^1.6.3",
42+
"@floating-ui/dom": "^1.6.12",
4343
"@hashicorp/design-system-tokens": "^2.2.1",
4444
"@hashicorp/flight-icons": "^3.7.0",
4545
"clipboard-polyfill": "^4.1.0",

packages/components/src/modifiers/hds-anchored-position.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ export const getFloatingUIOptions = (
133133
middleware.push(
134134
size({
135135
apply({ rects, elements }) {
136-
Object.assign(elements.floating.style, {
137-
width: `${rects.reference.width}px`,
136+
// wrap Object.assign inside a requestAnimationFrame to avoid ResizeObserver loop limit exceeded error
137+
// https://github.com/floating-ui/floating-ui/issues/1740
138+
requestAnimationFrame(() => {
139+
Object.assign(elements.floating.style, {
140+
width: `${rects.reference.width}px`,
141+
});
138142
});
139143
},
140144
})

showcase/tests/integration/components/hds/dropdown/index-test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
import { module, test, skip } from 'qunit';
6+
import { module, test } from 'qunit';
77
import { setupRenderingTest } from 'ember-qunit';
88
import { render, click } from '@ember/test-helpers';
99
import { hbs } from 'ember-cli-htmlbars';
@@ -172,8 +172,7 @@ module('Integration | Component | hds/dropdown/index', function (hooks) {
172172
assert.dom('.hds-dropdown__content').hasStyle({ width: '248px' });
173173
});
174174

175-
// flaky erroring with 'ResizeObserver loop completed with undelivered notifications.'
176-
skip('it should render the content with the same width as the ToggleButton if @matchToggleWidth is set', async function (assert) {
175+
test('it should render the content with the same width as the ToggleButton if @matchToggleWidth is set', async function (assert) {
177176
await render(hbs`
178177
<Hds::Dropdown id="test-dropdown" @matchToggleWidth={{true}} as |D|>
179178
<D.ToggleButton {{style width="200px"}} @text="toggle button" id="test-toggle-button" />

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -3080,7 +3080,7 @@ __metadata:
30803080
languageName: node
30813081
linkType: hard
30823082

3083-
"@floating-ui/dom@npm:^1.6.3":
3083+
"@floating-ui/dom@npm:^1.6.12":
30843084
version: 1.6.12
30853085
resolution: "@floating-ui/dom@npm:1.6.12"
30863086
dependencies:
@@ -3902,7 +3902,7 @@ __metadata:
39023902
"@ember/test-waiters": "npm:^3.1.0"
39033903
"@embroider/addon-dev": "npm:^4.3.1"
39043904
"@embroider/addon-shim": "npm:^1.8.7"
3905-
"@floating-ui/dom": "npm:^1.6.3"
3905+
"@floating-ui/dom": "npm:^1.6.12"
39063906
"@glimmer/component": "npm:^1.1.2"
39073907
"@glimmer/tracking": "npm:^1.1.2"
39083908
"@glint/core": "npm:^1.4.0"

0 commit comments

Comments
 (0)