angular / angular/components

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

Ouverte
#29,703 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
area: cdk/menu firefox P4
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par reproduire le problème dans l’exemple officiel de menu contextuel de CDK avec Firefox, puis examinez le comportement de CdkContextMenuTrigger et de CdkMenu concernant la sélection de texte et le focus. La tâche est considérée comme terminée lorsqu’il a été déterminé si le texte sélectionné peut rester sélectionné à l’ouverture du menu contextuel, ou lorsque la limitation de Firefox est clairement documentée si ce n’est pas possible.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.