Open nwhittaker opened 12 months ago
Potential option for a fix:
otherFocusableRadioButtons.filter(Boolean).forEach((radioButton) => {
forceUpdate(radioButton);
});
@geospatialem, I don't think that snippet is adequate since the Boolean
filter will still pass for pre-hydrated radio buttons, right?
I updated the issue description to clarify when I think the error is occurring:
…is calling
forceUpdate()
on the other<calcite-radio-button>
elements in the group after they're inserted into the DOM but before they've hydrated.
Maybe we only call forceUpdate if the build is a browser?
Something like
if (Build.isBrowser) {
otherFocusableRadioButtons.filter(Boolean).forEach((radioButton) => {
forceUpdate(radioButton);
});
}
Maybe we only call forceUpdate if the build is a browser?
Build.isBrowser
check(?)forceUpdate
at other points in the component's lifecycle/watch changes. It's really only calling it during connectedCallback()
that has the problem.Boolean
filter isn't doing anything. It'd need to reject non-hydrated radio buttons to have the, I believe, intended effect.@nwhittaker Are you still on version 1.11.0? v2 bumped the Stencil version, which fixed some component lifecycle issues we noticed.
In any case, I think checking for Build.isBrowser
might not help since forceUpdate
already does under the hood.
@nwhittaker I'll reach out to you directly for more info as I haven't been able to repro. 😞
Quick update: reached out to @nwhittaker and he'll be testing with v2 to confirm whether the issue is still present.
I tested with v2.1.0 and am seeing the same error:
Error run: https://github.com/ArcGIS/acadia-web/actions/runs/7492111875/job/20394912129?pr=4492#step:5:661 Problematic test case: https://github.com/ArcGIS/acadia-web/blob/d1c5bd512405e67d1c04448e9ae906eb8f24d2ba/packages/field-apps-custom-elements/src/components/radio-button-group/radio-button-group.stories.ts#L79
Reallocating to target in April as the test mentioned is currently being skipped, and additional R&D is needed to determine a fix.
This may no longer be an issue once #10310 lands.
Issue #10310 has been closed, this issue is ready for re-evaluation.
cc @geospatialem,@DitwanP
Spike to determine if the above PR mitigates the above.
Check existing issues
Actual Behavior
A
<calcite-radio-button-group>
within a storybookStoryFn
sometimes throws aTypeError: Cannot read properties of undefined (reading '$hostElement$')
error when running the storybook tests in CI.Expected Behavior
This error is not thrown.
Reproduction Sample
https://developers.arcgis.com/calcite-design-system/components/radio-button-group/
Reproduction Steps
I don't have a reduced test case since the issue is intermittent and likely stems from race conditions.
In a storybook
StoryFn
, I have this snippet within a custom component'sdetails
slot:The issue seems to have cropped up after recently upgrading to both Calcite 1.11 and Storybook 7.5.
Reproduction Version
1.11.0
Relevant Info
Looking at the stacktrace, I suspect
updateTabIndexOfOtherRadioButtonsInGroup()
is callingforceUpdate()
on the other<calcite-radio-button>
elements in the group after they're inserted into the DOM but before they've hydrated.Regression?
No response
Priority impact
p2 - want for current milestone
Impact
This issue impacts our PR process where we have to manually re-run these tests until they pass.
Calcite package
Esri team
ArcGIS Field Apps