Skip to content

[EuiRange] trackWidth does not update after mount #6846

Closed

Description

@breehall

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.

Screen.Recording.2023-06-15.at.4.09.46.PM.mov

Activity

  1. self-assigned this
    on Jun 15, 2023
  2. cee-chen commented on Jun 19, 2023

    @cee-chen
    Contributor

    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.

  3. cee-chen commented on Jun 26, 2023

    @cee-chen
    Contributor

    @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!

  4. e40pud commented on Dec 6, 2023

    @e40pud

    @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

    <div
        style={{
            display: active ? undefined : "none",
        }}
    >
    

    Right now, what we do, we forcibly re-add EuiRange component each time we active parent component.

  5. JasonStoltz commented on Dec 6, 2023

    @JasonStoltz
    Contributor

    @e40pud Thank you for your response. I've reopened the issue and we'll take a second look at it.

  6. added
    ⚠️ needs validation
    on Dec 18, 2023
  7. self-assigned this
    on Dec 18, 2023
  8. cee-chen commented on Jan 2, 2024

    @cee-chen
    Contributor

    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 EuiAccordion display: none state/CSS, which presumably is causing the range to have an incorrect 0 width on mount.

  9. removed
    ⚠️ needs validation
    on Jan 3, 2024
  10. changed the title [-][EuiRange] `trackWidth` not set when component is memoized[/-] [+][EuiRange] `trackWidth` does not update after mount[/+] on Jan 3, 2024
  11. cee-chen commented on Jan 3, 2024

    @cee-chen
    Contributor

    @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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions