Grid: AllowDetailView and AllowRowClick Conflict when enabled together

Đang mở Phù hợp với người mới
#1,388 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách xem cách thành phần Grid xử lý lượt nhấp vào hàng và sự kiện của chế độ xem chi tiết, sau đó theo dõi cách lượt nhấp vào nút mở rộng đến OnRowClick. Tái hiện hành vi với cả hai tùy chọn được bật và xác nhận rằng nút mở rộng vẫn mở chế độ xem chi tiết mà không gọi callback nhấp vào hàng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug
In the Grid component, setting both AllowDetailView and AllowRowClick to true causes both behaviors to be triggered when a row is clicked, resulting in unexpected behavior.

To Reproduce

  1. Add a Grid component.
  2. Set AllowRowClick="true" and OnRowClick="SomeFunction".
  3. Set AllowDetailView="true".
  4. Build and run the application, then click the Grid’s expand button.
  5. The row expands, and the OnRowClick behavior is triggered at the same time.

Expected behavior
When both AllowDetailView and AllowRowClick are enabled, clicking the expand button on the left should not trigger OnRowClick.
Alternatively, if this is the expected behavior, an exception should be thrown when both options are enabled.
Using OnRowDoubleClick works around the issue, but it doesn’t provide a good user experience.

Versions:

  • .NET Version: .NET 10
  • BlazorBootstrap: 4.0.0
  • Blazor WebAssembly / Server: Server
  • Blazor Interactive Render Mode: Server
  • Blazor Interactivity Location: Global

Sample code

@page "/Test"
@attribute [StreamRendering]

<Grid TItem="string" Class="table table-bordered" DataProvider="GridDataProviderAsync" OnRowClick="OnRowClick" AllowRowClick="true" AllowDetailView="true">

    <GridColumn TItem="string" HeaderText="Text" PropertyName="text" SortKeySelector="item => item">
        @context
    </GridColumn>
            
    <GridDetailView TItem="string">
        <Grid TItem="string" Class="table table-bordered" Data="@(new[] { context })">

            <GridColumn TItem="string" Context="text" HeaderText="Head" PropertyName="Head">
                @text.Substring(0, 1)
            </GridColumn>
            <GridColumn TItem="string" Context="text" HeaderText="Tail" PropertyName="Tail">
                @text.Substring(text.Length - 1, 1)
            </GridColumn>
            <GridColumn TItem="string" Context="text" HeaderText="Length" PropertyName="Length">
                @text.Length
            </GridColumn>

        </Grid>
    </GridDetailView>

</Grid>

@code
{
    [Inject]
    public required NavigationManager NavManager { get; set; }

    private async Task<GridDataProviderResult<string>> GridDataProviderAsync(GridDataProviderRequest<string> request)
    {
        var random = new Random();
        var data = Enumerable.Range(0, 100).Select(_ => new string(Enumerable.Range(0, 8).Select(__ => (char)random.Next('A', 'Z' + 1)).ToArray())).ToList();

        return request.ApplyTo(data);
    }

    private void OnRowClick(GridRowEventArgs<string> args)
    {
        var uri = $"https://google.com/search?q={args.Item}";
        NavManager.NavigateTo(uri);
    }
}

Desktop:

  • OS: Windows 11
  • Browser: Edge
  • Version: 157
Ngôn ngữ chính
HTML
Star
1.2k
Fork
111
Merge trung bình
4 phút
Pull request đã merge (30 ngày)
55

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vikramlearning/blazorbootstrap

Tất cả issue của vikramlearning/blazorbootstrap

Issue tương tự

Thêm issue về Web Dev

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.