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

Allow adding ToolBarItems to specifi places on the ToolBar #5894

Closed
yuvipanda opened this issue Jan 21, 2019 · 3 comments · Fixed by #5896
Closed

Allow adding ToolBarItems to specifi places on the ToolBar #5894

yuvipanda opened this issue Jan 21, 2019 · 3 comments · Fixed by #5896

Comments

@yuvipanda
Copy link
Contributor

@yuvipanda yuvipanda commented Jan 21, 2019

Right now, if I want to insert a specific toolbar item after another specific item (say, a 'download' after a 'save') there's no easy way to do this reliably. I can count indexes and use insertItem, but those change as other plugins also add items.

Instead, it'd be nice to have a insertAfter or insertBefore method that takes as a parameter a toolbar item name (which is already required), and inserts the given item before or after that name. This lets multiple plugins co-ordinate layout and ordering.

@ian-r-rose
Copy link
Member

@ian-r-rose ian-r-rose commented Jan 21, 2019

Thanks @yuvipanda! I think this is a good first issue for a new contributor. You would add new functions to the Toolbar class, defined here:

export class Toolbar<T extends Widget = Widget> extends Widget {

These functions, insertBefore and insertAfter would iterate over the names of the items currently in the toolbar looking for the requested one, then call this.insertItem at the appropriate index.

@ntdef
Copy link
Contributor

@ntdef ntdef commented Jan 22, 2019

I've made a pull request (#5896) if anyone wants to review.

@yuvipanda
Copy link
Contributor Author

@yuvipanda yuvipanda commented Jan 24, 2019

@ntdef that's awesome! <3 thank you for working on it! Very much appreciated :)

@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants