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

feat(table): add row, column buttons outside of table #6540

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

luka-nextcloud
Copy link
Contributor

@luka-nextcloud luka-nextcloud commented Oct 17, 2024

📝 Summary

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🚧 TODO

  • check if rows and columns can be added / removed and disable buttons accordingly
  • drop colspan=1, rowspan=1, etc from rendered html - first attempt at this failed

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

@juliusknorr
Copy link
Member

Seems like a user interface change so please provide some screenshots ;)

@luka-nextcloud
Copy link
Contributor Author

Yes, I will. It's not yet ready for review.

@luka-nextcloud
Copy link
Contributor Author

Screenshot & video
image

demo.webm

@luka-nextcloud luka-nextcloud added enhancement New feature or request 3. to review labels Oct 22, 2024
@luka-nextcloud
Copy link
Contributor Author

@nextcloud/designers Could you please give me your feedback regarding the button? :)

Copy link
Member

@jancborchardt jancborchardt left a comment

Choose a reason for hiding this comment

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

Looks very nice!

When a new row or column gets added, it should also get focused. The first relevant cell, so leftmost for new rows and topmost for new columns.

Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

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

In general works really well, thanks for tackling this. I have left some comments in the code. Also I think a cypress test that adds a row or column using one of the buttons would be great to avoid regressions later on.

@@ -322,10 +322,10 @@ div.ProseMirror {

table {
border-spacing: 0;
width: calc(100% - 50px);
width: calc(100% - 84px);
Copy link
Member

Choose a reason for hiding this comment

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

How about adding a comment about what 84px are and how they're compounded?

table-layout: auto;
white-space: normal; // force text to wrapping
margin-bottom: 1em;
margin-bottom: 4em;
Copy link
Member

Choose a reason for hiding this comment

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

Same here. Also, I wonder why the button size is 34px on the side, but 3em (different unit) on the bottom. Maybe instead use calc(1em + 34px) instead?

</NcButton>
<NcButton v-if="isEditable"
class="table-add-row"
:aria-label="t('text', 'Add row after')"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:aria-label="t('text', 'Add row after')"
:aria-label="t('text', 'Add row below')"

Maybe better language-wise?

const lastRowNode = this.node.lastChild
this.editor.chain()
.focus()
.setTextSelection(this.getPos() + this.node?.nodeSize - lastRowNode.nodeSize + 1)
Copy link
Member

Choose a reason for hiding this comment

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

The node? seems error-prone here. If this.node was faulty here, initialization of lastRowNode above would already fail, and it would probably lead to unwanted side-effects, no? If this.node can really be faulty here, I'd suggest to catch this properly and not do anything in this case.

}
</script>

<style scoped lang="scss">
.table-wrapper {
position: relative;
overflow-x: auto;

&.focused {
Copy link
Member

Choose a reason for hiding this comment

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

I'd expect the &.focused ruleset to be inside the .table-add-column and .table-add-row rulesets below, but that's rather nitpicking.

@@ -58,6 +59,17 @@ export default TableCell.extend({
}
},

renderHTML({ HTMLAttributes }) {
const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate a bit on why this is necessary? I didn't grasp what the colspan and rowspan attributes are used for before.


&:hover {
opacity: 1;
visibility: unset;
Copy link
Member

Choose a reason for hiding this comment

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

In my understanding the visibility: unset is superfluous. The button already becomes visible on table focus, and it cannot be hovered when invisible: hidden anyway.

@@ -4,7 +4,7 @@
-->

<template>
<NodeViewWrapper data-text-el="table-view" class="table-wrapper">
<NodeViewWrapper data-text-el="table-view" class="table-wrapper" :class="{ 'focused': isFocused }">
Copy link
Member

Choose a reason for hiding this comment

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

So far, the buttons only become visible when the table is focussed (i.e. the cursor is inside it). How about also making them visible when the table is hovered? I'd expect this from a user experience perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review enhancement New feature or request
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Table tweaks
4 participants