-
Notifications
You must be signed in to change notification settings - Fork 332
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
Replace remove block button with dropdown that can display multiple actions #6599
Conversation
margin-right: 15px; | ||
} | ||
|
||
.action { |
There was a problem hiding this comment.
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
.eslintrc.json
Outdated
@@ -203,7 +203,6 @@ | |||
"indentLogicalExpressions": true | |||
} | |||
], | |||
"react/jsx-no-bind": "error", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
dea7b7d
to
9b851d7
Compare
} | ||
|
||
return ( | ||
<li key={index}> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🙈
}} | ||
> |
There was a problem hiding this comment.
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.
}} | |
> | |
}} | |
type='button' | |
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md to avoid this in future.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 🙈
src/Sulu/Bundle/AdminBundle/Resources/js/components/BlockCollection/SortableBlock.js
Show resolved
Hide resolved
src/Sulu/Bundle/AdminBundle/Resources/js/components/BlockCollection/BlockCollection.js
Show resolved
Hide resolved
@@ -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" |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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:
sulu/src/Sulu/Bundle/AdminBundle/Resources/js/components/Block/Block.js
Lines 100 to 106 in c298925
<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
There was a problem hiding this comment.
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 ;)
97e8397
to
a86e643
Compare
f71ea98
to
800ff87
Compare
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