Skip to content

Conversation

@pereriksson
Copy link

@pereriksson pereriksson commented Dec 5, 2025

There is currently a flag for time pickers called roundBy5, but it is never used as it is always set to false.

Since I would like to use it, I propose it is exposed to the developer.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 5, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Expose the existing timepicker roundBy5 option through the public options interface, give it a default value, and pass it into setHand so that minute selection can be snapped to 5-minute increments when enabled.

Sequence diagram for TimePicker hand movement with roundBy5 option

sequenceDiagram
  actor User
  participant TimePicker
  participant State
  participant setHand

  User->>TimePicker: mousedown on clock face
  TimePicker->>State: compute dx, dy from click position
  TimePicker->>setHand: setHand(dx, dy, options.roundBy5)

  User->>TimePicker: drag (mousemove)
  TimePicker->>State: update x, y, moved = true
  TimePicker->>setHand: setHand(x, y, options.roundBy5, true)
  setHand-->>TimePicker: hand position (snapped if roundBy5)
  TimePicker-->>User: update clock UI
Loading

Class diagram for updated TimepickerOptions and TimePicker interactions

classDiagram
  class TimepickerOptions {
    +boolean~optional~ autoClose
    +boolean~optional~ twelveHour
    +boolean~optional~ vibrate
    +boolean~optional~ roundBy5
    +function~optional~ onOpen()
    +function~optional~ onOpenStart()
    +function~optional~ onOpenEnd()
  }

  class DefaultTimepickerOptions {
    +boolean autoClose = false
    +boolean twelveHour = true
    +boolean vibrate = true
    +boolean roundBy5 = false
    +function onOpen()
    +function onOpenStart()
    +function onOpenEnd()
  }

  class TimePicker {
    +TimepickerOptions options
    +State state
    +handleMousedown(event)
    +handleMousemove(event)
  }

  class State {
    +number dx
    +number dy
    +number x0
    +number y0
    +boolean moved
  }

  class setHand {
    +setHand(dx, dy, roundBy5, moved?)
  }

  DefaultTimepickerOptions --> TimepickerOptions : implements
  TimePicker --> TimepickerOptions : uses options
  TimePicker --> State : maintains
  TimePicker --> setHand : calls
  TimepickerOptions --> setHand : provides roundBy5
Loading

File-Level Changes

Change Details Files
Expose and wire the roundBy5 option into the timepicker behavior.
  • Add optional roundBy5 boolean field to TimepickerOptions so consumers can configure it.
  • Extend defaultOptions with roundBy5: false to maintain current behavior by default.
  • Pass options.roundBy5 into setHand during initial hand setting on click so the flag controls rounding.
  • Pass options.roundBy5 into setHand during drag handling so rounding behavior is consistent while dragging.
packages/lib/src/timepicker.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • When passing options.roundBy5 into setHand, consider normalizing it with a default (e.g. !!options.roundBy5) in case an options object is constructed without going through the defaultOptions merge path.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When passing `options.roundBy5` into `setHand`, consider normalizing it with a default (e.g. `!!options.roundBy5`) in case an options object is constructed without going through the `defaultOptions` merge path.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@pereriksson
Copy link
Author

@erikvullings what do you think about this small improvement?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant