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

breaking(Tab): change menu.aligned prop to menuPosition and infer menu.tabular from it #2499

Conversation

amankkg
Copy link
Contributor

@amankkg amankkg commented Feb 6, 2018

BREAKING CHANGE

The menu.aligned prop has been replaced with menuPosition. This keeps the menu prop strictly equal to the <Menu />'s props.

Before

const menu = {  fluid: true, vertical: true, aligned: 'right' }

<Tab panes={[...]} menu={menu} />

After

const menu = {  fluid: true,  vertical: true }

<Tab panes={[...]} menu={menu} menuPosition="right" />

The current implementation of Tab's menu.aligned prop triggers React's design-time warning on redundant aligned prop being passed down to div of underlying Menu.
In this change new dedicated menuPosition prop is introduced and old menu.aligned prop is removed.

Remaining behavior is not changed:

  • supported values is PropTypes.oneOf(['left', 'right'])
  • non-required and default value is 'left'

Resolves #2430

@welcome
Copy link

welcome bot commented Feb 6, 2018

💖 Thanks for opening this pull request! 💖

Here is a list of things that will help get it across the finish line:

  • Run yarn lint locally to catch formatting errors. This will fix some errors automatically, commit and push any changes.
  • Run yarn test locally to catch errors. This ensures all components still behave as they should.
  • Run yarn start to run the doc site locally and try a few pages, ensuring everything is in good working order.
  • Include tests when adding/changing behavior.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@codecov-io
Copy link

codecov-io commented Feb 6, 2018

Codecov Report

Merging #2499 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2499      +/-   ##
==========================================
+ Coverage   99.74%   99.74%   +<.01%     
==========================================
  Files         160      160              
  Lines        2758     2762       +4     
==========================================
+ Hits         2751     2755       +4     
  Misses          7        7
Impacted Files Coverage Δ
src/modules/Tab/Tab.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8114d8b...f7a66da. Read the comment docs.

@amankkg
Copy link
Contributor Author

amankkg commented Feb 6, 2018

Any feedback on prop name? menuPosition is OK too, IMO, sounds similar to Input's label and labelPosition props.

@levithomason
Copy link
Member

Ah, yes, menuPosition is more fitting.

@amankkg amankkg changed the title breaking(Tab): change menu.aligned prop to menuAligned breaking(Tab): change menu.aligned prop to menuPosition Feb 7, 2018
@amankkg
Copy link
Contributor Author

amankkg commented Feb 7, 2018

Done!

@levithomason
Copy link
Member

Vertical Example

This example shows the tabs on the wrong side of the pane.

http://localhost:8080/modules/tab#tab-example-vertical-true

image

It seems we also have conflicting configuration now between the props menu.tabular and menuPosition. The menu.tabular prop should only take a boolean now that we have menuPosition. The direction of a tabular menu should be derived from the menuPosition.

@levithomason
Copy link
Member

I see, we'll still need menuPosition for the cases where you need position a non-tabular menu, such as a secondary menu.

I think it would be ideal to infer the tabular value from the menuPosition, if provided. So, that menuPosition='right' would automatically use a tabular='right' menu. Otherwise, the user has to configure both to "right" to make it appear correctly.

@amankkg
Copy link
Contributor Author

amankkg commented Feb 8, 2018

@levithomason

This example shows the tabs on the wrong side of the pane.

But why? If there is no menuPosition prop provided - it defaults to 'left'. And tabular="right" is only applied on Menu itself.

It seems we also have conflicting configuration now between the props menu.tabular and menuPosition. The menu.tabular prop should only take a boolean now that we have menuPosition. The direction of a tabular menu should be derived from the menuPosition.

I think it would be ideal to infer the tabular value from the menuPosition, if provided. So, that menuPosition='right' would automatically use a tabular='right' menu. Otherwise, the user has to configure both to "right" to make it appear correctly.

OK. We can should infer menu's tabular value from the menuPosition prop.
But, as user, I'd expect that Tab's menu API to align Menu's API. And Menu's API on tabular prop is expecting one of false | true | 'right'. So menu.tabular shouldn't accept boolean only.
And, if we're going to infer menu's tabular value, then Menu's tabular should accept 'left' also, this way we can specify Tab's menu.tabular as 'left' and menuPosition as 'right'.

const { activeIndex } = this.state

if (menu.tabular === true) {
menu.tabular = menuPosition === 'left' || 'right'
}
Copy link
Contributor Author

@amankkg amankkg Feb 8, 2018

Choose a reason for hiding this comment

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

menu.tabular = menuPosition === 'left' || 'right'
since there is no support for value 'left' in menu.tabular, we cannot set menu.tabular as 'left' AND menuPosition as 'right'

@amankkg
Copy link
Contributor Author

amankkg commented Feb 8, 2018

There is the logic of inferring of menu.tabular at 4d6a9c4 (comments are visible here).
If it's OK we need to update Menu propTypes and handle its tabular's value 'left' to be similar as true.
And fix tests, docs, etc.

@@ -114,7 +114,7 @@ class Tab extends Component {
const { activeIndex } = this.state

if (menu.tabular === true) {
menu.tabular = menuPosition === 'left' || 'right'
menu.tabular = menuPosition
}
Copy link
Contributor Author

@amankkg amankkg Feb 8, 2018

Choose a reason for hiding this comment

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

menu.tabular = menuPosition
this way we can specify menu.tabular as true if we just want to infer it from menuPosition
and as left or right if we want to specify ourselves

@amankkg
Copy link
Contributor Author

amankkg commented Feb 9, 2018

Now menu.tabular supports 'left' and it derives final value only if set to true. This way we can specify menu.tabular: 'left' and menuPosition: 'right' simultaneously (which will became tabular: true, not 'right').

@amankkg
Copy link
Contributor Author

amankkg commented Feb 9, 2018

I'd like to see Menu's tabular accepting 'left' also, even if its behavior remains similar to false. If so, Tab's menu prop would match Menu's props.

@amankkg
Copy link
Contributor Author

amankkg commented Feb 9, 2018

@levithomason I'll update the rest of the code if it's OK now.

@amankkg amankkg changed the title breaking(Tab): change menu.aligned prop to menuPosition breaking(Tab): change menu.aligned prop to menuPosition and infer menu.tabular from it Feb 9, 2018
@levithomason
Copy link
Member

I'd like to see Menu's tabular accepting 'left' also, even if its behavior remains similar to false. If so, Tab's menu prop would match Menu's props.

While I agree, let's save this for another PR. There are many cases of props taking boolean values along with a "right" or "bottom" but not accepting a "left" or "top".

The only other comment I have here is that I think we need to simplify the prop computation. The prop description has too many considerations given the scope of the feature (positioning the menu). Ideally, the user wouldn't have to think or make decisions beyond a left/right decision for the position. Anything more than this I feel reduces the utility of the component.

I apologize I as I don't have time to offer suggestions at the moment. Feel free to offer your thoughts on this.

@levithomason
Copy link
Member

@amankkg How's your availability looking for wrapping this one up?

@amankkg
Copy link
Contributor Author

amankkg commented Feb 19, 2018 via email

@amankkg
Copy link
Contributor Author

amankkg commented Feb 19, 2018

@levithomason

While I agree, let's save this for another PR.

Yep, sure.

@amankkg
Copy link
Contributor Author

amankkg commented Feb 20, 2018

@levithomason there is an ugly prop computation because of Menu's aligned prop API is one of...

There are many cases of props taking boolean values along with a "right" or "bottom" but not accepting a "left" or "top"

Not sure if this can simplified without decreasing Menu's customizeability.
Otherwise, there is no way to specify menuPosition to be right and menu.tabular to be left at the same time, as example.

Any comments and proposals are welcome, especially on props description in documentation.

upd: example case

@amankkg
Copy link
Contributor Author

amankkg commented Mar 10, 2018

Updated test cases and added new example for menu.tabular prop in docs.

@levithomason
Copy link
Member

levithomason commented Mar 18, 2018

This looks great! I will do some cleanup and merge this today.

@levithomason levithomason force-pushed the fix/tab-menu-warning-redundant-prop-aligned branch from 9ad74c0 to c76ed41 Compare March 18, 2018 17:38
@levithomason
Copy link
Member

Added/updated docs, updated logic a bit and tests. Now menuPosition always wins, but, menu.tabular can also be used to set the position, just as with a <Menu />.

@amankkg
Copy link
Contributor Author

amankkg commented Apr 2, 2018

@levithomason what is the status of this PR? What can I do to help?

@levithomason
Copy link
Member

Sorry for the delay. Merging master and running tests and we'll ship this!

@levithomason levithomason force-pushed the fix/tab-menu-warning-redundant-prop-aligned branch from 98031df to 148f973 Compare April 30, 2018 19:18
@levithomason
Copy link
Member

Rebased and updated. Really hoping to merge this now...

@layershifter
Copy link
Member

Removed cruft example, tests passed 👍

@layershifter layershifter merged commit e3ac2bd into Semantic-Org:master May 1, 2018
@welcome
Copy link

welcome bot commented May 1, 2018

Congrats on merging your first pull request! 🎉🎉🎉

robot victory dance

@levithomason
Copy link
Member

Released in semantic-ui-react@0.80.0.

@amankkg amankkg deleted the fix/tab-menu-warning-redundant-prop-aligned branch May 2, 2018 06:56
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.

4 participants