angular / angular/components

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

オープン
#29,703 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area: cdk/menu firefox P4
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

### 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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、Firefox で公式の CDK コンテキストメニューの例において問題を再現し、その後、テキスト選択とフォーカスに関する CdkContextMenuTrigger と CdkMenu の動作を調査します。コンテキストメニューを開いたときに選択したテキストを選択されたままにできるかどうかを判断するか、それが不可能な場合は Firefox の制限を明確に文書化できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。