Skip to content

A few improvements to the Tabs component#797

Merged
bryphe merged 8 commits into
onivim:masterfrom
glennsl:tabs
Oct 14, 2019
Merged

A few improvements to the Tabs component#797
bryphe merged 8 commits into
onivim:masterfrom
glennsl:tabs

Conversation

@glennsl
Copy link
Copy Markdown
Member

@glennsl glennsl commented Oct 1, 2019

  • Enables using the mousewheel to scroll through the tabs
  • Brings the active tab into view when it changes
  • Includes the icon in the clickable area of the tab
  • Simplifies tabInfo by adding editorId and removing the properties that were precomputed based on it, active, onClick and onClose.

Depends on revery-ui/revery#579 to fix tabs overflowing

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Oct 1, 2019

CLA assistant check
All committers have signed the CLA.

Comment thread src/UI/EditorGroupView.re
editorId: v.editorId,
title,
modified,
active: EditorGroup.isActiveEditor(editorGroup, v.editorId),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for cleaning this up! 🎉

Comment thread src/UI/Tabs.re

let viewStyle = Style.[flexDirection(`Row)];
let measureWidth: option(node) => int = fun
| Some(outer) => outer#measurements().width
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I didn't realize you could use the fun keyword like this - cool!

Comment thread src/UI/Tabs.re
};

let isPendingRender: option(node) => bool = fun
| Some(outer) => outer#firstChild()#firstChild()#measurements().width < 0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow! Nice find on how to figure out if a render is pending.

I wonder if we could provide a helper API on the Revery side to make this more ergonomic?

Copy link
Copy Markdown
Member Author

@glennsl glennsl Oct 2, 2019

Choose a reason for hiding this comment

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

I hope so!

This is basically just what i tried to do, and found to return garbage data in some circumstances. It worries me a bit that such a widely used API can just return garbage like that. It kind of makes the point of using a safe language a bit moot. Should it be considered a bug in revery?

The easy fix is probably just to have measurements() return an option, have it detect MIN_INT on some measure and return None in that case. But that will still require this onDimensionsChange hack everywhere this can happen. Perhaps we could have measurements() take a callback instead, that's called when rendering is done?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It worries me a bit that such a widely used API can just return garbage like that. It kind of makes the point of using a safe language a bit moot. Should it be considered a bug in revery?

Agree 100% ! Good observation. The garbage is a problem - we should be leveraging the language to make it safe and easy to create UI (like we do for things like hooks).

Perhaps we could have measurements() take a callback instead, that's called when rendering is done?

I like this idea!

Comment thread src/UI/Tabs.re Outdated
(
hooks,
<View
onMouseWheel=scroll
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! 🎉

@bryphe
Copy link
Copy Markdown
Member

bryphe commented Oct 12, 2019

Hi @glennsl ,

Sorry - realized the CI was busted for this change! I'll merge up master for this and re-kickoff the CI.

So excited to have this in 🎉

@bryphe
Copy link
Copy Markdown
Member

bryphe commented Oct 12, 2019

Oh - looks like I need to bring in the overflow Revery fix to it. Looking into that.

@bryphe
Copy link
Copy Markdown
Member

bryphe commented Oct 14, 2019

Found and fixed an additional overflow issue: revery-ui/revery#599

Brought it in; I'll merge up and this should be good-to-go! 👍

@bryphe
Copy link
Copy Markdown
Member

bryphe commented Oct 14, 2019

Green now - thanks @glennsl for the incredible contribution! 🎉

@bryphe bryphe merged commit 70bc84e into onivim:master Oct 14, 2019
@glennsl glennsl deleted the tabs branch October 14, 2019 19:55
dycu pushed a commit to dycu/oni2 that referenced this pull request Oct 21, 2019
* bounded mousewheel scrolling

* include icon in clickable tab area

* bring active tab into view when changed

* simplify tabInfo

* cleanup

* fix unused variable warnings

* Formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants