Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Collapse main menu options in a hamburger menu #489
Collapse main menu options in a hamburger menu #489
Changes from 6 commits
2f46ffc
59291de
4f9f0e1
dfe9abd
b5402a8
f7501b7
1e1c494
de210ed
4e8c625
c14d733
fcc357b
8cca0f6
aae3aca
36cefff
92fbf60
8598c45
3f0c8e6
76b3125
f1f3879
705a855
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Hi @krassowski, I remembered that we added this optional argument here in Lumino just in case other applications didn't want to have the collapse behavior. I can check if this argument is set to True in Jupyter, and that should be the solution of not seeing this feature active
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.
Do we need to expose this method, or could it be private?
_overflowIndex
and_menuItemSizes
are private so overriding this method would be rather difficult as it standsIf it should be protected to allow overriding, maybe it could return a new (private) interface, like:
then you can have a single private variable set as:
and use it with unpacking:
Then it would be also easier to unit-test it too.
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 tried to create the interface, but soon enough I found myself wondering that I needed to update the overflow index value in multiple spots, so I'm not sure if we need the interface. For now I just converted the function to private.
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 reduce the number of lines in this resize handler, maybe you want to replace
this._menuItemSizes
with a_getMenuItemSizes
method that handles this caching of the menu item sizes.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 can move this block of code to another function but I would need to send almost all the variables defined in the function as a parameter, so I don't know what's best...
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.
It might just be me, but would it be better if the entire function were moved into a separate method? Like so:
I'm not sure that's the best name for the method, but there are a few reasons why I think having such a method would be a good idea:
this._evtResize
) from there.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.
Maybe worth adding a new optional method in
IRenderer
, e.g.createOverflowMenu()
that would allow to customise this? In particular downstream may want to customize label. You could provide a default implementation inRenderer
.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 see that 4e8c625 added
renderOverflowItem
which is a copy-paste ofrenderItem
and is used to replace it; I think that we should . This might be useful (though I would avoid copy-pasting the code and instead just invoke the other method by default), but this is not what I had in mind.I meant to suggest that we should wrap rendering of the overflow menu so that the
...
. and mnemonic can be customized downstream. The lines that I commented on would then become for example:This is very minor, I don't think we have to do this. To limit the surface of API changes I would also suggest reverting
renderOverflowItem
for now - if this is needed in the future we can always add it (removing things is more difficult).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 think @krassowski's suggestion to remove
renderOverflowItem
until it turns out it is necessary is a good plan.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.
It looks like this one will lead to the state being always delayed by one tick. It is not bad in itself if this is a conscious decision made as a performance-UX tradeoff. Could we document this?
One thing to consider is whether we should wrap it in an extra
requestAnimationFrame
to protect against layout trashing.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.
How do I wrap it in a
requestAnimationFrame
?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.
It would be something like:
I have not tested if this helps. You would need to record a profile in developer tools when you resize the page to trigger collapsing before and after applying the change and compare. If you have the profiles it should be obvious from the time spend on forced style recalculation/layout whether it is worth waiting for the next frame or not.