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

Replace remove block button with dropdown that can display multiple actions #6599

Merged
merged 12 commits into from
May 23, 2022

Conversation

niklasnatter
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? yes
Related issues/PRs #6436
License MIT

What's in this PR?

This PR replaces the remove block button that is displayed in the upper right corner of blocks with a dropdown that allows to display multiple possible actions.

Why?

This is a preparation for implementing a copy feature for blocks like described in #6436

margin-right: 15px;
}

.action {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this matches the implementation of the download media popover and the autocomplete suggestions popover

@alexander-schranz alexander-schranz added this to the Release 2.5 milestone May 9, 2022
@alexander-schranz alexander-schranz added the UX Affecting the end user label May 9, 2022
.eslintrc.json Outdated
@@ -203,7 +203,6 @@
"indentLogicalExpressions": true
}
],
"react/jsx-no-bind": "error",
Copy link
Member

Choose a reason for hiding this comment

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

The rule sounds for me something important in case of performance: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md

So not sure if I would remove it. I think I would go with keep it and add ignore where really required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i removed the rule because it makes list rendering a pain as you need to extract a component for the list item. in this case, i think the rule makes the code even slower because we need to instantiate a whole component for each item instead of just an arrow function 🙈

but yeah, i guess there are cases where it improves performance too. i will readd it.

Copy link
Member

Choose a reason for hiding this comment

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

we need to instantiate a whole component for each item instead of just an arrow function

I see, but theoretically the component is initialized only once. And the function is created for every render so it also can in this case improve the performance. I'm just not sure how much mobx maybe would effect here things and maybe avoid rerender here something.
Atleast we also created in this cases also for Select Option own component to avoid this kind of problems. So I personally would go the save way of introducing also here a MenuOption or what the best name is here.

@niklasnatter niklasnatter marked this pull request as ready for review May 16, 2022 15:41
}

return (
<li key={index}>
Copy link
Member

Choose a reason for hiding this comment

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

To be consistent I would create a MenuOption and or MenuItem component or what best matching name is. So we also get rid of the react/jsx-no-bind ignore 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.

i extracted a ActionPopoverItem. but it really feels cumbersome to do this, i am not a fan of the react/jsx-no-bind rule 🙈

Comment on lines 49 to 50
}}
>
Copy link
Member

Choose a reason for hiding this comment

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

a button should always define its type else it accidently gets a submit button when wrapped inside a form tag.

Suggested change
}}
>
}}
type='button'
>

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the rule 🙂 i guess i will need to update a lot of snapshots

@@ -154,18 +155,43 @@ class BlockCollection<T: string, U: {type: T}> extends React.Component<Props<T,
onChange(newValue);
};

hasMaximumReached() {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about htis rename. Think hasMaximumReached present it better as maxOccursReached but was never a fan of the occurs word 🙈

@@ -154,14 +154,14 @@ exports[`Render block with schema 1`] = `
class="iconButtons"
>
<span
aria-label="su-trash-alt"
class="su-trash-alt clickable"
aria-label="su-more-circle"
Copy link
Member

@alexander-schranz alexander-schranz May 16, 2022

Choose a reason for hiding this comment

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

Any easy way to make this better accessible?

E.g.:

<ul class="iconButtons"
   <li>
       <button ...>
           <span class="su-more-circle" aria-hidden="true"/>
           <span class="sr-only">More</span>
       </button>
   </li>
   <li>
       <button ...>
           <span class="su-collapse-vertical" aria-hidden="true"/>
           <span class="sr-only">Collapse Block</span>
       </button>
   </li>
</ul>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is rendered using the Icon component:

<div className={blockStyles.iconButtons}>
{onSettingsClick && <Icon name="su-cog" onClick={onSettingsClick} />}
{onRemove && <Icon name="su-trash-alt" onClick={onRemove} />}
{onCollapse && onExpand &&
<Icon name="su-angle-up" onClick={this.handleCollapse} />
}
</div>

i can check if anything breaks if i use the Button component

Copy link
Member

Choose a reason for hiding this comment

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

I would not use the button component just us a button tag ;)

@alexander-schranz alexander-schranz merged commit 398310d into sulu:2.5 May 23, 2022
@alexander-schranz alexander-schranz added Feature New functionality not yet included in Sulu and removed Feature New functionality not yet included in Sulu labels May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX Affecting the end user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants