Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[List Feature] Backspace on empty list. #2316

Merged
merged 6 commits into from
Jan 15, 2024
Merged

Conversation

juliaroldi
Copy link
Contributor

@juliaroldi juliaroldi commented Jan 8, 2024

If the content edit list features are turned off, it is not possible to delete a list with just one list item. Therefore, the deleteList step was added to delete list when the backspace key is pressed on a list with no content.

How to test:
Turn off the content edit features:
Screenshot 2024-01-09 at 10 38 11
Screenshot 2024-01-09 at 10 38 02

  1. Create a list a item
  2. Type something
  3. Press backspace to delete all content.
  4. The list must be deleted

backspaceOnList

@juliaroldi juliaroldi changed the title U/juliaroldi/delete list [List Feature] Backspace on empty list. Jan 9, 2024
@juliaroldi juliaroldi marked this pull request as ready for review January 9, 2024 13:47
const { paragraph, marker, path } = context.insertPoint;

if (context.deleteResult == 'nothingToDelete' || context.deleteResult == 'notDeleted') {
const index = getClosestAncestorBlockGroupIndex(path, ['ListItem']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the 3rd parameter "['TableCell']" so if there is table under list, do not delete list. And add test case for this scenario

(paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br'))
) {
item.levels = [];
context.deleteResult = 'singleChar';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel here it would be better to use 'range' so that undo snapshot will be added.

(paragraph.segments.length == 1 ||
(paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br'))
) {
item.levels = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, if the list is a nested list, should we remove all the list like right now, or should we outdent to the previous level? Probably with levels.pop()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally am ok with either. Maybe @jvillalobos can comment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we delete a nested list, the delete result returns 'Range', then it not impacted by this code. I tested in word desktop and it removes the list.

@juliaroldi juliaroldi merged commit ca636df into master Jan 15, 2024
7 checks passed
@juliaroldi juliaroldi deleted the u/juliaroldi/delete-list branch January 15, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants