You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiRange] trackWidth does not update after mount #6846
Describe the bug
PR elastic/kibana#159635 in Kibana introduces memoization to the Security - Cases creation page. During the case creation process (step 2), an EuiRange component is used, but on the first render all of the tick values appear stacked on top of each other. After changing the value of the range (and on all subsequent renders), the tick values appear normal.
It seems that the trackWidth is being set to 0 and is not properly setting until after the first render.
This can be replicated by checking out the PR above locally and navigating to app/security/rules/create. In the Custom Query field text, enter a * and continue to the next section. Upon first render, the tick marks will appear stacked, but when you change the value they appear normally.
Can we repro this in a CodeSandbox rather than requiring a Kibana PR? The fact that it requires that step is a bit of a red flag - it means consumer implementation is overly complex or an edge case. To be honest, my first inclination to resolve this issue would be to tell consumers to simply not memoize EuiRange/EuiDualRange.
@marshallmain as a heads up, we're going to go with advising not memoizing EuiRange/EuiDualRange until we can get a EUI-only reproduction of the issue. If you're interested in that, please comment and we can re-open this issue!
@cee-chenhere I tried to create a CodeSandbox example of the broken state.
Unfortunately, in our case we cannot avoid memoizing EuiRange. We memoize a bigger parent component due to performance enhancements which we did to improve rule management experience. Parent component is in the DOM but visual appearance controlled by css via
<div
style={{
display: active ? undefined : "none",
}}
>
Right now, what we do, we forcibly re-add EuiRange component each time we active parent component.
it appears to be instead related to the EuiAccordiondisplay: none state/CSS, which presumably is causing the range to have an incorrect 0 width on mount.
changed the title [-][EuiRange] `trackWidth` not set when component is memoized[/-][+][EuiRange] `trackWidth` does not update after mount[/+]on Jan 3, 2024
@marshallmain@e40pud This should be fixed in the next EUI release and Kibana upgrade (will probably take another ~2 weeks to land in Kibana main). Once it does, feel free to remove your forced remount - and please do let us know if something went horribly awry and the fix doesn't work for some reason!
Activity
cee-chen commentedon Jun 19, 2023
Can we repro this in a CodeSandbox rather than requiring a Kibana PR? The fact that it requires that step is a bit of a red flag - it means consumer implementation is overly complex or an edge case. To be honest, my first inclination to resolve this issue would be to tell consumers to simply not memoize
EuiRange/EuiDualRange.[Security Solution] Memoize components in create rules page (#159635)
[Security Solution] Memoize components in create rules page (elastic#…
[8.9] [Security Solution] Memoize components in create rules page (#1…
cee-chen commentedon Jun 26, 2023
@marshallmain as a heads up, we're going to go with advising not memoizing
EuiRange/EuiDualRangeuntil we can get a EUI-only reproduction of the issue. If you're interested in that, please comment and we can re-open this issue![Security Solution] Default Risk score slide bar values are overlaid …
[Security Solution] Default Risk score slide bar values are overlaid …
[8.9] [Security Solution] Default Risk score slide bar values are ove…
[Security Solution] Default Risk score slide bar values are overlaid …
e40pud commentedon Dec 6, 2023
@cee-chen here I tried to create a CodeSandbox example of the broken state.
Unfortunately, in our case we cannot avoid memoizing EuiRange. We memoize a bigger parent component due to performance enhancements which we did to improve rule management experience. Parent component is in the DOM but visual appearance controlled by css via
Right now, what we do, we forcibly re-add EuiRange component each time we active parent component.
JasonStoltz commentedon Dec 6, 2023
@e40pud Thank you for your response. I've reopened the issue and we'll take a second look at it.
[Security Solution] Default Risk score slide bar values are overlaid …
[Security Solution] Default Risk score slide bar values are overlaid …
[8.12] [Security Solution] Default Risk score slide bar values are ov…
cee-chen commentedon Jan 2, 2024
Interestingly enough, the bug isn't actually related to the
useMemo/memoization as it occurs even without it:https://codesandbox.io/p/sandbox/magical-merkle-cz388d?file=%252Fdemo.tsx
it appears to be instead related to
the EuiAccordiondisplay: nonestate/CSS, which presumably is causing the range to have an incorrect 0 width on mount.[-][EuiRange] `trackWidth` not set when component is memoized[/-][+][EuiRange] `trackWidth` does not update after mount[/+]cee-chen commentedon Jan 3, 2024
@marshallmain @e40pud This should be fixed in the next EUI release and Kibana upgrade (will probably take another ~2 weeks to land in Kibana main). Once it does, feel free to remove your forced remount - and please do let us know if something went horribly awry and the fix doesn't work for some reason!