Skip to content

Add ReadOnly parameter implementation to BitTimePicker (#9977)#10071

Merged
msynk merged 1 commit intobitfoundation:developfrom
Cyrus-Sushiant:9977-fix-readonly-bittimepicker
Feb 27, 2025
Merged

Add ReadOnly parameter implementation to BitTimePicker (#9977)#10071
msynk merged 1 commit intobitfoundation:developfrom
Cyrus-Sushiant:9977-fix-readonly-bittimepicker

Conversation

@Cyrus-Sushiant
Copy link
Member

@Cyrus-Sushiant Cyrus-Sushiant commented Feb 27, 2025

This closes #9977

Summary by CodeRabbit

  • New Features

    • Enhanced the time picker’s behavior by ensuring input fields correctly enforce a read-only state, preventing unwanted user interactions.
  • Documentation

    • Updated the demo experience by adding "Standalone" and "ReadOnly" sections, and reorganizing examples to better highlight different configuration options, including time formats and disabled states.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

The pull request updates the TimePicker component to support enhanced read-only functionality. Input elements now consider both the text input allowance and an explicit read-only property. Event handlers in the code-behind check for a read-only state to prevent user interactions, and the demo pages have been reorganized to include new standalone and read-only sections. Additional variables and comprehensive sample code have been added or updated to demonstrate various TimePicker configurations.

Changes

Files Change Summary
src/BlazorUI/Bit.BlazorUI/Components/Inputs/_Pickers/TimePicker/BitTimePicker.razor
src/BlazorUI/Bit.BlazorUI/Components/Inputs/_Pickers/TimePicker/BitTimePicker.razor.cs
Updated the readonly attribute on input fields to account for an explicit ReadOnly property. Added conditional checks in event handlers (HandleOnAmClick, HandleOnPmClick, HandleOnPointerDown) to exit early when in read-only mode.
src/BlazorUI/Demo/Client/…/TimePicker/BitTimePickerDemo.razor
src/BlazorUI/Demo/Client/…/TimePicker/BitTimePickerDemo.razor.cs
src/BlazorUI/Demo/Client/…/TimePicker/BitTimePickerDemo.razor.samples.cs
Reorganized the demo UI by adding new "Standalone" and "ReadOnly" sections. Updated demo sections references and IDs, introduced a new readOnlyTime variable, and removed redundant example code. Comprehensive Razor samples now illustrate various TimePicker configurations.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant TP as BitTimePicker Component
    U->>TP: Trigger time input event (e.g., AM/PM click)
    TP->>TP: Check if ReadOnly (or IsEnabled)
    alt ReadOnly is true
        TP-->>U: Exit without action
    else
        TP->>TP: Process interaction (adjust time)
        TP-->>U: Return updated time value
    end
Loading

Poem

I'm a little rabbit, hopping through the code,
With read-only checks that lighten the load.
Inputs now whisper "no edit allowed,"
While demos show features that make us proud.
With carrots and code, I celebrate the sight,
Happy changes, coding day and night!
🥕🐰 Hop on, let your code take flight!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/_Pickers/TimePicker/BitTimePicker.razor.cs (1)

9-257: ⚠️ Potential issue

Missing ReadOnly property definition

I don't see the ReadOnly property defined in the BitTimePicker class, yet it's being used in several places in the component.

Add the property definition for ReadOnly:

/// <summary>
/// Whether or not the Text field of the TimePicker is underlined.
/// </summary>
[Parameter] public bool Underlined { get; set; }

+ /// <summary>
+ /// Whether the TimePicker is in read-only mode. When true, the value cannot be changed by user interaction.
+ /// </summary>
+ [Parameter] public bool ReadOnly { get; set; }

/// <summary>
/// The format of the time in the time-picker
/// </summary>
[Parameter] public string? ValueFormat { get; set; }
🧹 Nitpick comments (1)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TimePicker/BitTimePickerDemo.razor.cs (1)

1-587: Consider adding ReadOnly parameter definition to componentParameters

The ReadOnly parameter should be documented in the componentParameters list to provide users with information about this new property.

Add the ReadOnly parameter to the componentParameters list:

new()
{
    Name = "ValueFormat",
    Type = "string?",
    DefaultValue = "null",
    Description = @"The format of the time in the TimePicker like ""HH:mm"".",
},
+ new()
+ {
+     Name = "ReadOnly",
+     Type = "bool",
+     DefaultValue = "false",
+     Description = "Whether the TimePicker is in read-only mode. When true, the value cannot be changed by user interaction.",
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a200381 and d6618f5.

📒 Files selected for processing (5)
  • src/BlazorUI/Bit.BlazorUI/Components/Inputs/_Pickers/TimePicker/BitTimePicker.razor (3 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Inputs/_Pickers/TimePicker/BitTimePicker.razor.cs (3 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TimePicker/BitTimePickerDemo.razor (6 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TimePicker/BitTimePickerDemo.razor.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TimePicker/BitTimePickerDemo.razor.samples.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build and test
🔇 Additional comments (11)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/_Pickers/TimePicker/BitTimePicker.razor (3)

43-43: Input accessibility enhancement with ReadOnly property

The update to include ReadOnly in the readonly attribute condition properly implements the read-only state for the main input field.


101-101: ReadOnly property added to hour input

This change consistently applies the ReadOnly state to the hour input, ensuring users cannot edit hours when the component is in read-only mode.


135-135: ReadOnly property added to minute input

This change consistently applies the ReadOnly state to the minute input, ensuring users cannot edit minutes when the component is in read-only mode.

src/BlazorUI/Bit.BlazorUI/Components/Inputs/_Pickers/TimePicker/BitTimePicker.razor.cs (3)

483-483: Early return when ReadOnly for AM selection

This change prevents interactions with AM selection when the component is in read-only mode, properly implementing the read-only behavior.


492-492: Early return when ReadOnly for PM selection

This change prevents interactions with PM selection when the component is in read-only mode, properly implementing the read-only behavior.


587-587: Early return when ReadOnly for increment/decrement actions

This change prevents interactions with the increment/decrement buttons when the component is in read-only mode, properly implementing the read-only behavior.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TimePicker/BitTimePickerDemo.razor.cs (1)

562-562: Added readOnlyTime field for demo purposes

The new readOnlyTime field properly supports the demonstration of the ReadOnly functionality in the demo page.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TimePicker/BitTimePickerDemo.razor.samples.cs (2)

52-58: Well-structured examples for ReadOnly functionality

The ReadOnly examples demonstrate different configurations (with/without AllowTextInput, standalone mode, and with different time formats), providing users with a clear understanding of how to use this new property.


1-252: Comprehensive sample code structure

The new samples file is well-organized with a variety of examples covering all features of the BitTimePicker component, making it easy for users to understand how to implement different configurations.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/TimePicker/BitTimePickerDemo.razor (2)

82-98: Well-implemented standalone section.

The addition of the standalone TimePicker examples provides useful demonstration of the component in this mode. The examples cover basic usage, format options, and disabled state with a preset value.


100-114: Great implementation of the ReadOnly parameter.

This section effectively demonstrates the new ReadOnly functionality across different configurations:

  • Basic ReadOnly mode
  • ReadOnly with text input allowed
  • Standalone ReadOnly mode
  • Standalone ReadOnly with different time format

The parameter description accurately explains that it makes the time picker non-editable, preventing users from changing the time value.

@msynk msynk merged commit 119de02 into bitfoundation:develop Feb 27, 2025
3 checks passed
@Cyrus-Sushiant Cyrus-Sushiant deleted the 9977-fix-readonly-bittimepicker branch March 22, 2025 17:04
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.

ReadOnly attribute in BitTimePicker not implemented correctly

2 participants