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

ENH Add action dropdown. Move delete button. #345

Conversation

raissanorth
Copy link
Contributor

@raissanorth raissanorth commented Aug 22, 2018

Partially resolves #322

The ACs for the above ticket include styling. Outstanding is the amendment of the size of the toggle button icon, which depends on silverstripe/silverstripe-admin#610 (review), so I'll make a seperate PR for this.

Changes in this PR:

  • add an action menu
  • move the action menu into it's own container within the header given that a 'caret' button will be added shortly
  • move the delete button into the actionmenu's dropdownmenu and change the form action into a simple button, since a separate task will look into adding children to the action menu

Depends on silverstripe/silverstripe-admin#610 to prevent the delete button events to bubble up the element itself (the latter would cause a redirect to the edit page)

const { link } = this.props;

// TODO Replace with something more unique than a class name, perhaps add an ID?
if (event.target.className === 'action-menu__toggle btn btn--no-text btn--icon-xl font-icon-dot-3 btn btn-secondary') {
Copy link
Contributor

Choose a reason for hiding this comment

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

To start with you could check whether the target's classList contains action-menu__toggle

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we did something similar with the Delete button - you should maybe check that. I think it has some code in the click handler for the delete button that stops propagation so the click event doesn't bubble to the parent component as well

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the issue here is that we can't easily alter the click handler for the toggle button. That's taken care of by the ActionMenu component as a part of admin. Perhaps that's something to add to silverstripe/silverstripe-admin#610

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Maybe the click handler needs a callback prop you can pass in e.g. beforeHandleClick which is given the event argument so we can tell it to stop propagation

/>
<div className="element-editor-header__actions">
<ActionMenuComponent
id={this.props.id}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we prefix this with something unique to the actions menu maybe like element-editor-actions-${id} or something? Note id is destructured already at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Changed it as suggested.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also FYI - IDs that start with a number is invalid HTML!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😮

Copy link
Contributor

@robbieaverill robbieaverill left a comment

Choose a reason for hiding this comment

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

Looks good =) Let's get the builds green then merge

@@ -20,7 +20,7 @@ class Element extends Component {
/**
* Take the user to the GridFieldDetailForm to edit the record
*/
handleClick() {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this any 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.

Do you say that because this functionality is moving into the caret button in the header? And we don't want to replicate this if the user clicks anywhere on the element?!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's mentioning that you've added event but you're not using it anymore 🙂

Copy link
Contributor Author

@raissanorth raissanorth Aug 23, 2018

Choose a reason for hiding this comment

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

ah, i removed that since - locally. will be in the next rebase.

@raissanorth raissanorth force-pushed the pulls/master/add-actiondropdown branch from a8f0795 to 6ffde24 Compare August 23, 2018 05:07
@ScopeyNZ ScopeyNZ merged commit 348bfb5 into silverstripe:master Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an ActionDropdown for various options on Blocks
3 participants