Skip to content

feat(ui5-table): add range selection to selection feature#9205

Merged
DonkeyCo merged 7 commits intomainfrom
feat-range-selection
Jun 24, 2024
Merged

feat(ui5-table): add range selection to selection feature#9205
DonkeyCo merged 7 commits intomainfrom
feat-range-selection

Conversation

@DonkeyCo
Copy link
Copy Markdown
Contributor

In "Multiple" selection mode, it is now possible to select ranges with a) mouse or b) keyboard.

a) Select a row via checkbox and Shift + Click on another checkbox to select the range
b) Select a row and Shift + Up/Down to extend your range selection.

DonkeyCo added 2 commits June 13, 2024 12:06
In "Multiple" selection mode, it is now possible to select ranges with a) mouse or b) keyboard.

a) Select a row via checkbox and Shift + Click on another checkbox to select the range.
b) Select a row and Shift + Up/Down to extend your range selection.
@DonkeyCo DonkeyCo requested review from aborjinik and nnaydenow June 13, 2024 15:42
selectionChanged = true;
}

// Workaround required due to bug with mouse, where the checkbox stays unchecked, but the row is selected.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is weird we need to check this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

100% agree. Maybe I'm missing something

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can this be related with the user interaction happens on the checkbox, where user interaction is also using the checked/selected property under the hood.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could be the case, yes. Removed the custom handling for click in the Selection feature (and restored it in the TableHeaderRow, etc.) and it seems to work fine now?

}

_isSelectionCheckbox(e: Event) {
return e.composedPath().some((el: EventTarget) => (el as HTMLElement).id === "selection-component");
Copy link
Copy Markdown
Contributor

@aborjinik aborjinik Jun 14, 2024

Choose a reason for hiding this comment

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

any element might have an id with selection-component

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tried to use a unique attribute instead (data-ui5-table-selection-component)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Feel free to suggest any other ideas

@DonkeyCo DonkeyCo changed the title feat(ui5-table): add range selection to selection feat(ui5-table): add range selection to selection feature Jun 18, 2024
@DonkeyCo DonkeyCo requested a review from aborjinik June 19, 2024 10:00

const focusedElement = getActiveElement(); // Assumption: The focused element is always the "next" row after navigation.

if (!isInstanceOfTableRow(focusedElement) && !this._rangeSelection?.isMouse) {
Copy link
Copy Markdown
Contributor

@aborjinik aborjinik Jun 20, 2024

Choose a reason for hiding this comment

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

if I select the last row and shift arrow down and then I am on the growing button should then the range selection stop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tough to say. When you hold down the key, maybe the range selection should continue?
Tried it out in the m.Table and at least there it is not possible to focus the growing button with Arrow keys.
But there is some weird behaviour there.
Maybe range selection should only explicitly stop, when releasing the shift key?

@DonkeyCo DonkeyCo requested a review from aborjinik June 24, 2024 05:58

{{#*inline "growingRow"}}
<ui5-table-row id="growing-row">
<ui5-table-row id="growing-row" ui5-growing-row>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is the reason for that?
we can identify it from its id and it is single for the table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same reasoning, why I've added ui5-table-row-base.

Applications could go ahead an set a random row with id="growing-row" and then, it is not possible to discern our internal growing row from the external one (e.g. in a focusin, keyup event handler)

Very unlikely scenario, but just to be on the safe side and have no ID restrictions. Of course this issue could also occur, if the app is setting the ui5-growing-row attribute, but then I think it is quite malicious from their side.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for rows I understand but not for the table
what I mean is instead of checking the attribute we can check ` === table._growingRow``
but ok

@DonkeyCo DonkeyCo requested a review from aborjinik June 24, 2024 09:32
@DonkeyCo DonkeyCo merged commit 55d99d2 into main Jun 24, 2024
@DonkeyCo DonkeyCo deleted the feat-range-selection branch June 24, 2024 13:32
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.

2 participants