Skip to content

[Bug]: Null reference in useSlider() when <Slider /> unmounts before window mouseUp event fires #24727

@MLoughry

Description

@MLoughry

Library

React / v8 (@fluentui/react)

System Info

System:
    OS: Linux 5.4 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (32) x64 Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
    Memory: 49.57 GB / 62.81 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash

Are you reporting Accessibility issue?

No response

Reproduction

https://codepen.io/MLoughry/pen/YzLwddZ

Bug Description

Actual Behavior

When you click on a <Slider />, and the component unmounts while the mouse button is down, and you then move the mosue while the mouse button is still down, there is a null-ref in useSlider()

Uncaught TypeError: Cannot read properties of null (reading 'getBoundingClientRect')
  at @fluentui/react/lib/components/src/components/Slider/useSlider.ts:269
  at @fluentui/react/lib/components/src/components/Slider/useSlider.ts:287

Expected Behavior

There is no null-ref errror

Logs

No response

Requested priority

High

Products/sites affected

Blocking Outlook rollout

Are you willing to submit a PR to fix?

yes

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions