Frontend School

Dynamic Range Slider for Data Filtering

Machine Coding
medium

Dynamic Range Slider for Data Filtering

Medium
React
Frontend
UI
Component
slider
Drag and Drop

Overview

Many Atlassian products involve filtering large datasets (e.g., Jira issues by story points, Confluence pages by last modified date, Trello cards by estimated time). A robust and intuitive range slider is crucial for users to quickly narrow down results without complex input fields. This problem focuses on building a reusable range slider component that allows users to select a continuous range from a predefined minimum and maximum value, with visual feedback and dynamic value display.

What you need to do / Task

  1. Develop a RangeSlider component: This component should accept min, max, initialMin, initialMax, and an onChange callback as props.
  2. Implement draggable handles: Users should be able to drag two distinct handles (one for the lower bound, one for the upper bound) along a track to select a range.
  3. Update displayed values: As handles are dragged, the current selected range values should be displayed dynamically.
  4. Prevent handle overlap: The lower bound handle should not be able to go past the upper bound handle, and vice-versa.
  5. Invoke onChange: The onChange callback should be triggered with the new [min, max] values whenever the selected range changes.

UI/UX expectations

  • Layout: The slider should consist of a horizontal track. Two circular handles should be positioned on this track, representing the lower and upper bounds of the selected range. A filled section of the track should visually represent the currently selected range between the two handles.
  • Value Display: The current min and max values of the selected range should be displayed clearly above the slider track.
  • Interaction: Handles should be draggable using a mouse. The interaction should feel smooth and responsive.

Acceptance criteria

  • The component renders with two handles and a track.
  • Handles can be dragged independently within the min/max bounds of the slider.
  • The lower handle cannot be dragged beyond the upper handle's current position.
  • The upper handle cannot be dragged beyond the lower handle's current position.
  • The visual range between handles updates as they are dragged.
  • The displayed numerical values update in real-time as handles are dragged.
  • The onChange callback is invoked with the correct [min, max] values on range change.

Constraints

Constraints & assumptions

  • Environment: React (TypeScript) in a browser environment.
  • Libraries: You may use basic React hooks (useState, useRef, useEffect, useCallback). No external UI libraries (e.g., Ant Design, Material UI) are allowed for the slider itself.
  • Data: Values will be integers. The range will be positive.
  • Browser support: Modern browsers (Chrome, Firefox, Safari).
  • Styling: Basic CSS for layout and visual feedback. No need for pixel-perfect design, but it should be functional and visually distinct.

Out of scope

  • Full accessibility support (e.g., ARIA attributes, comprehensive keyboard navigation).
  • Responsiveness for different screen sizes.
  • Support for negative numbers or floating-point values.
  • Performance optimizations for extremely large ranges (e.g., 100,000+ items).
  • Tooltips on handles showing the exact value while dragging.

What interviewers evaluate

  • Component Design: How well the RangeSlider component is structured, its props, and internal state management.
  • Interaction Logic: Correctness and robustness of the drag-and-drop logic for handles, including boundary and overlap constraints.
  • State Management: Effective use of React state and hooks to manage slider values and UI updates.
  • Code Quality: Readability, maintainability, and adherence to best practices (e.g., separation of concerns).

Loading editor...