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

[UI Framework] Add KuiContextMenu. #14183

Merged

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Sep 26, 2017

Ports over many improvements from K7 (#14108).

  • Update KuiPopover to use K7 code.
  • Add KuiPanelSimple for use within KuiPopover; it's just the K7 KuiPanel renamed.
  • Refactor/rewrite KuiExpression and KuiExpressionButton to depend upon KuiPopover.

To review:

  • Take a look at the KuiPanelSimple, KuiPopover, KuiContextMenu, and KuiExpression examples and source code.
  • Ignore most changes to files in the ui_framework/src/global_styling directory and changes to the files that are not related to the above components.
  • Check out Dashboard panels to make sure the popover still works correctly.

context_menu

@cjcenizal cjcenizal added Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. v6.1.0 v7.0.0 labels Sep 26, 2017
@cjcenizal cjcenizal force-pushed the improvement/accessible-context-menu branch 2 times, most recently from cd962b9 to a35df3a Compare September 27, 2017 00:15
@cjcenizal
Copy link
Contributor Author

@stacey-gammon Could you take a look at this and advise me on how this affects #13853? There was a merge conflict with the changes you made to popover.scss, but I just overwrote the changes you made. Maybe we can pair up and work through the changes to make sure I haven't broken anything for you.

@timroes Could you take a look and let me know what you think of these changes in terms of accessibility?

A more general code review would also be welcome from each of you if you have time.

@kimjoar
Copy link
Contributor

kimjoar commented Sep 27, 2017

I only skimmed through some of the changes, but in general it looks like we need more component tests here. Some of these components are fairly complex.

@cjcenizal
Copy link
Contributor Author

@kjbekkelund You got me! Thanks for keeping me honest. I just pushed a bunch of tests. Would you mind taking a look?

@timroes I also made some tweaks to the KuiCodeEditor tests. Could you look them over please?

@stacey-gammon I also updated the snapshot for the dashboard_panel test. Could you take a look and let me know what you think?

Thanks, everyone!

@cjcenizal cjcenizal force-pushed the improvement/accessible-context-menu branch 2 times, most recently from c58e181 to 0716794 Compare September 28, 2017 03:43
@cjcenizal cjcenizal requested a review from kimjoar September 29, 2017 01:32
Copy link
Contributor

@kimjoar kimjoar left a comment

Choose a reason for hiding this comment

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

This is touching a ton of files and has lots of little changes, so it's not the easiest to review. But the tests are definitely looking better now. I haven't gone through every component as I just didn't have time right now.


const classes = classNames(
{
'kuiPopoverTitle': children,
Copy link
Contributor

Choose a reason for hiding this comment

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

children isn't clear here. It needs a test, plus we should maybe change this to children != null or something like that? It's difficult to understand the intention right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch... I don't think this is necessary at all.

@cjcenizal
Copy link
Contributor Author

@kjbekkelund Thanks man. I'm going to try to break this PR up a bit to make it easier to review. I'll let you know when it's been deflated.

@timroes
Copy link
Contributor

timroes commented Oct 2, 2017

This really is a rather large PR and it looks fine. I skipped through the code and as @kjbekkelund already mentioned, it's touching quite some files :-) So I also feel hard to just say, everything is fine (though it looks like everything is working).

@cjcenizal cjcenizal force-pushed the improvement/accessible-context-menu branch from 7c511ab to 4702788 Compare October 2, 2017 15:55
@cjcenizal
Copy link
Contributor Author

@kjbekkelund @timroes I've extracted out as much as I possibly can from this PR. Could you take another look? It's still a daunting PR based solely on size, but I think it becomes easier if you review one component at a time:

  1. KuiPanelSimple
  2. KuiPopover
    3 KuiContextMenu
  3. KuiExpression

@stacey-gammon Could you take a look at the Dashboard panel and verify that it still functions correctly?

@kimjoar
Copy link
Contributor

kimjoar commented Oct 2, 2017

The last commit (Remove unnecessary logic from KuiPopoverTitle.) added tons of generated code +7,102 −8, which doesn't seem relevant to this PR(?)

@cjcenizal cjcenizal force-pushed the improvement/accessible-context-menu branch from 4702788 to 98a91bc Compare October 2, 2017 17:54
@cjcenizal
Copy link
Contributor Author

Good catch @kjbekkelund, fixed. Sorry about that.

@stacey-gammon
Copy link
Contributor

I think there is a bug when you click on Edit visualization. I get a quick error that disappears on the screen - something about can't read style of null, then redirects to edit the visualization. Doesn't seem to happen in master.

Otherwise, it works great!

@cjcenizal
Copy link
Contributor Author

@stacey-gammon great catch, fixed!

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

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

Wow, the UX of that is awesome!

I have a few suggestions on how to improve the React components' apis, mainly of KuiContextMenu itself:

  • Split out the transition part into a HorizontalSwipeTransition component or similar.
  • Replace the confusing idToPanelMap and idToPreviousPanelMap props with a flattened panels map, where each panel references its children via id
  • Use an array of panel ids as the currentPanelPath state so we can derive the "previous" panel from the state.

Let's maybe talk about this synchronously some time?

@cjcenizal
Copy link
Contributor Author

@weltenwort I just pushed a commit which uses a flat panels prop as you suggest. Great idea!

@cjcenizal
Copy link
Contributor Author

@weltenwort Thanks for all of your help! I like your suggestion but I think I'll need some help implementing it. The problem we need to overcome is that the application state doesn't map cleanly to the visual state due to the fade-out transition when the the ContextMenu closes. In the owner, state.isPopoverOpen determines when the the ContextMenu is visible. If we simply don't render the ContextMenu when this is false then the ContextMenu will abruptly disappear. But we don't want that; we want the CSS transition to take effect and gently fade it out.

We could solve this by adding a onCloseComplete prop or something, so the owner can re-render when the transition is done, but I'm not sure it's worth it. What do you think?

@weltenwort
Copy link
Member

@cjcenizal, I think what you are looking for is https://github.com/reactjs/react-transition-group with its <TransitionGroup> and <CSSTransition> components. The <TransitionGroup> keeps the "exiting" components around until the transition is done.

@cjcenizal
Copy link
Contributor Author

Ah ha! Thanks man!

- Update KuiPopover to use K7 code.
- Add KuiPanelSimple for use within KuiPopover; it's just the K7 KuiPanel renamed.
- Refactor/rewrite KuiExpression and KuiExpressionButton to depend upon KuiPopover.
- Add K7 shadow mixins and size and z-index vars to global_styling.
- Refactor tests to use a test subject selector to locate the hint element.
- Refine tests to leverage snapshots instead of DOM assertions.
- Update snapshot.
- Update Jest config to make snapshotComponent available to Kibana src.
- Move keyboard navigation logic into KuiContextPanel.
- Add example to doc site.
- Update tests.
…tMenuPanel.

- Rename 'current panel' to 'incoming panel' for cohesion with 'outgoing panel.'
@cjcenizal cjcenizal force-pushed the improvement/accessible-context-menu branch from 5796c71 to 9ab0a13 Compare October 11, 2017 04:08
@cjcenizal
Copy link
Contributor Author

cjcenizal commented Oct 11, 2017

@weltenwort I looked into CSSTransition and the related components but I wasn't sure how we could implement them in a way that made isVisible unnecessary. Maybe we can work on this together later?

I'm going to merge this because complementary parts of it have been looked over by different engineers, so I feel comfortable with the code's correctness and quality at this point.

@cjcenizal cjcenizal merged commit abcccd0 into elastic:master Oct 11, 2017
@cjcenizal cjcenizal deleted the improvement/accessible-context-menu branch October 11, 2017 16:11
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Oct 11, 2017
* Add KuiContextMenu.
- Update KuiPopover to use K7 code.
- Add KuiPanelSimple for use within KuiPopover; it's just the K7 KuiPanel renamed.
- Refactor/rewrite KuiExpression and KuiExpressionButton to depend upon KuiPopover.
- Add K7 shadow mixins and size and z-index vars to global_styling.

* Update Dashboard panel to use KuiContextMenu.
- Fix reloading issue when editing a visualization from within a dashboard.

* Completely refactor KuiContextMenu to enable a single panel.
- Move keyboard navigation logic into KuiContextPanel.
- Set focus on the item which shows the panel we're leaving within KuiContextMenu.
- Remove unnecessary logic from KuiPopoverTitle.
- Replace confusing idToPanelMap and idToPreviousPanelIdMap props with a panels prop.
- Replace panelRef prop with onHeightChange prop.
- Migrate transition state and logic from KuiContextMenu into KuiContextMenuPanel.
- Rename 'current panel' to 'incoming panel' for cohesion with 'outgoing panel.'
- Map panel items to panels up-front.
- Convert maps from state variables into instance variables.
cjcenizal added a commit that referenced this pull request Oct 11, 2017
* Add KuiContextMenu.
- Update KuiPopover to use K7 code.
- Add KuiPanelSimple for use within KuiPopover; it's just the K7 KuiPanel renamed.
- Refactor/rewrite KuiExpression and KuiExpressionButton to depend upon KuiPopover.
- Add K7 shadow mixins and size and z-index vars to global_styling.

* Update Dashboard panel to use KuiContextMenu.
- Fix reloading issue when editing a visualization from within a dashboard.

* Completely refactor KuiContextMenu to enable a single panel.
- Move keyboard navigation logic into KuiContextPanel.
- Set focus on the item which shows the panel we're leaving within KuiContextMenu.
- Remove unnecessary logic from KuiPopoverTitle.
- Replace confusing idToPanelMap and idToPreviousPanelIdMap props with a panels prop.
- Replace panelRef prop with onHeightChange prop.
- Migrate transition state and logic from KuiContextMenu into KuiContextMenuPanel.
- Rename 'current panel' to 'incoming panel' for cohesion with 'outgoing panel.'
- Map panel items to panels up-front.
- Convert maps from state variables into instance variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. v6.1.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants