angular / angular/components

bug(menu): opening CDK context menu loose text selection on Firefox

Đang mở
#29,703 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area: cdk/menu firefox P4
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Hi there,

I’ve been working with CdkContextMenuTrigger in conjunction with CdkMenu and attempting to implement a copy/paste feature. However, I’ve encountered an issue specifically in Firefox: when the context menu opens, the selected text is unexpectedly unselected.

After some investigation, it appears that Firefox may automatically deselect text when focus shifts to elements outside the text container. While this behavior might be a limitation inherent to Firefox, I believe it is worth documenting.

Additionally, it is worth noting that the official CDK context menu example includes mocked "copy" and "cut" options, which exacerbates this issue.

Is this behavior something that can be addressed, or is it an inherent limitation of how Firefox handles text selection and focus?

Thanks!

### Reproduction

StackBlitz link: cf. https://material.angular.io/cdk/menu/examples
Steps to reproduce:
1. Go to https://material.angular.io/cdk/menu/examples with Firefox
2. In "Context menu" example, try to select a portion of text and right click on it
3. See the menu is opened but the text is no more selected

### Expected Behavior

The text should remains selected

### Actual Behavior

The text is no more selected

### Environment

- Angular: 18.2.3
- CDK/Material: 18.2.3
- Browser(s): Firefox 130.0 (64 bits)
- Operating System (e.g. Windows, macOS, Ubuntu): Ubuntu 24.04

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện vấn đề trong ví dụ menu ngữ cảnh CDK chính thức với Firefox, sau đó kiểm tra hành vi của CdkContextMenuTrigger và CdkMenu liên quan đến việc chọn văn bản và tiêu điểm. Công việc được xem là hoàn tất khi xác định được liệu văn bản đã chọn có thể vẫn được chọn khi menu ngữ cảnh mở hay không, hoặc ghi lại rõ ràng giới hạn của Firefox nếu điều đó không thể thực hiện.

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

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

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.