basecamp / basecamp/trix

Add Link then Undo Leaves Behind Background Color Highlight

Open
#1,096 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
20k
Forks
1.1k
Avg merge
3d 12h
Merged PRs (30d)
13

Description

1. Select text.
2. Click the link icon and apply a link.
3. Click the undo button.

This leaves behind a `span` with `background-color: highlight;`. If you have a background color picker, that can be used to remove the color. Otherwise, you have to delete the selection and re-enter it to get the highlighting to go away.

When the editor opens a dialog it calls `freezeSelection` it uses the `frozen` attribute which uses a background color of `highlight`. When the dialog is recording the undo entry `recordUndoEntry` -> `createEntry` -> `this.composition.getSnapshot()` gets the current snapshot of the rich text which includes `attributes` that include `"frozen": true`.

Maybe `getSnapshot` should ignore the `frozen` attribute since that's an internal attribute that is only used to keep the selected text highlighted while the dialog is open?

One way to work around the issue is to disable the `frozen` attribute during the `trix-before-initialize` event with:

```javascript
Trix.config.textAttributes.frozen = {}
```

##### Details

* Trix version: 2.0.5

Contributor guide

No contributing guide indexed for this repository

Research direction

Trace the dialog flow through freezeSelection, recordUndoEntry, createEntry, and this.composition.getSnapshot(), focusing on how the frozen attribute enters the undo snapshot. Reproduce the link-then-undo steps in Trix 2.0.5, then verify that undo removes the link without leaving a span with background-color: highlight while dialog selection highlighting still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.