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

Can't select all list items with Shift + up arrow without selecting previous block #12656

Closed
jeremyfelt opened this issue Dec 6, 2018 · 12 comments · Fixed by #19721
Closed
Assignees
Labels
[Block] List Affects the List Block [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@jeremyfelt
Copy link
Member

jeremyfelt commented Dec 6, 2018

Describe the bug

In WordPress 5.0, given a list of at least 4 items in a list block, if I try to select all of those items with CMD + Shift + Left arrow and then Shift + Up arrow, all of the items except for the first can be selected as expected. As soon as I type Shift + Up arrow for the last item, the selection skips and becomes a multi-block selection.

To Reproduce
Steps to reproduce the behavior:

  1. Add a paragraph block
  2. Add a list block
  3. Type 4 or more list items
  4. Place cursor at the end of the last list item
  5. Type CMD + Shift + Left arrow (OSX) to select all text in the last item
  6. Type Shift + Up arrow to add the above list item to the selection
  7. Repeat

Expected behavior

I expect to be able to select each list item in the block so that I can copy/cut or otherwise manipulate the text.

Screenshots

list-item-select

Desktop (please complete the following information):

  • OS: Mac OS 10.12.6
  • Browser: Chrome
  • Version: 70.0.3538.110
@jeremyfelt
Copy link
Member Author

I've updated the original ticket description—this appears to only happen with 4 or more list items. In a list of 3 items, I'm able to select as expected.

Also: Using CMD + Shift + Up arrow when the cursor is at the end of the last item does work as expected and selects all text at once.

@swissspidy swissspidy added [Block] List Affects the List Block [Type] Bug An existing feature does not function as intended Needs Testing Needs further testing to be confirmed. labels Dec 7, 2018
@afercia
Copy link
Contributor

afercia commented Dec 8, 2018

@jeremyfelt is this similar to #12322 ? Seems to me the same thing happens also on paragraphs, with the same caveat: it's triggered with 4 or more lines of text.

@jeremyfelt
Copy link
Member Author

@afercia It seems like it. I have the same issue with paragraphs. I can imagine it's the same area of code that's responsible. Should we close this one as a duplicate?

@afercia
Copy link
Contributor

afercia commented Dec 8, 2018

Probably yes, I'd leave that to the Gutenteam though. For now, I'd remove the "Needs testing" label 🙂

@afercia afercia removed the Needs Testing Needs further testing to be confirmed. label Dec 8, 2018
@aduth
Copy link
Member

aduth commented Jan 9, 2019

Expect that the issue lies within the calculation of the vertical edge being traversed:

} else if ( isVertical && isVerticalEdge( target, isReverse ) ) {

/**
* Check whether the selection is vertically at the edge of the container.
*
* @param {Element} container Focusable element.
* @param {boolean} isReverse Set to true to check top, false for bottom.
*
* @return {boolean} True if at the edge, false if not.
*/
export function isVerticalEdge( container, isReverse ) {
if ( includes( [ 'INPUT', 'TEXTAREA' ], container.tagName ) ) {
return isHorizontalEdge( container, isReverse );
}
if ( ! container.isContentEditable ) {
return true;
}
const selection = window.getSelection();
const range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;
if ( ! range ) {
return false;
}
const rangeRect = getRectangleFromRange( range );
if ( ! rangeRect ) {
return false;
}
const buffer = rangeRect.height / 2;
const editableRect = container.getBoundingClientRect();
// Too low.
if ( isReverse && rangeRect.top - buffer > editableRect.top ) {
return false;
}
// Too high.
if ( ! isReverse && rangeRect.bottom + buffer < editableRect.bottom ) {
return false;
}
return true;
}

I encounter a similar issue with lists. It's not clear to me whether it's precisely the same:

  1. Insert a paragraph with some text
  2. Insert a list with a list item
  3. Add a new list item
  4. Indent the new list item
  5. Press Up

Expected: Caret moves to first list item
Actual: Caret moves to preceding paragraph

@ellatrix ellatrix added the [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... label Feb 11, 2019
@ellatrix
Copy link
Member

ellatrix commented Mar 15, 2019

I think this is alleviated by #14448, but it's still an issue only if the last item is less longer than the first item.

@aduth
Copy link
Member

aduth commented Mar 18, 2019

@ellatrix Can you clarify? I can no longer reproduce this at all, regardless of whether the first line is longer than the last.

list

@ellatrix
Copy link
Member

@aduth Sorry, I meant: if the last line is longer than the first. :)

@jeremyfelt
Copy link
Member Author

I just tested this in WordPress 5.1 with the Gutenberg 5.4.0 plugin activated and I think it is resolved. I can select the full list of items using the keyboard when the last item is longer or shorter than the first.

I had a similar issue with paragraphs and that is working now as well.

@aduth
Copy link
Member

aduth commented Apr 8, 2019

I can still reproduce the issue under the specific condition that the last entry in the list is longer than those preceding it.

list

@jeremyfelt
Copy link
Member Author

This seems to be resolved in WP 5.3.2 with Gutenberg 7.1.0.

list-selection

@aduth
Copy link
Member

aduth commented Dec 20, 2019

I'm still able to reproduce with the same characteristics as in my previous comment #12656 (comment) .

(macOS 10.15.1, Chrome 79.0.3945.88)

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] List Affects the List Block [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants