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

feat(popover-edit): experimental popover edit for tables (mvp) #15496

Merged
merged 1 commit into from Apr 3, 2019

Conversation

kseamon
Copy link
Collaborator

@kseamon kseamon commented Mar 15, 2019

Adds a new set of directives to cdk-experimental that allow editing of content in tables (including cdk-table). Will be expanded with additional functionality and Material-styled versions in coming PRs.

@kseamon kseamon requested a review from jelbourn as a code owner March 15, 2019 18:06
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 15, 2019
@kseamon kseamon force-pushed the popover-edit-mvp branch 8 times, most recently from 9aa4c30 to 46ec7c0 Compare March 18, 2019 15:01
@kseamon kseamon requested a review from mmalerba as a code owner March 18, 2019 15:01
Copy link
Contributor

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

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

Looks great, the examples are really helpful to see what it looks like as the end user, thanks for setting it up so we can see it in the demo app.

It would be valuable to create a simple case of using this with the MatTable just to make sure we have the right considerations for API. For example, common.ts contains '.mat-cellas a selector but this is in the CDK directory and should not be aware ofmat`. How do you want to provide that selector to the underlying logic so that it knows what to look out for?

src/cdk-experimental/popover-edit/common.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/common.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/common.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/edit-events.ts Outdated Show resolved Hide resolved
readonly hovering = new Subject<Element|null>();
readonly mouseMove = new Subject<Element|null>();

protected currentlyEditing: Element|null = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you anticipate this service being extended, if so, do you have a use case we can track to make sure we're correctly enabling that case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have anything specific in mind. I could make them private if that's preferred.

I'll be extending a bunch of the directives for the material versions but probably not the services.

src/cdk-experimental/popover-edit/edit-events.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/common.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/table-directives.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/table-directives.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/lens-directives.ts Outdated Show resolved Hide resolved
@kseamon
Copy link
Collaborator Author

kseamon commented Mar 20, 2019

Re: the mat-selectors

I plan to make mat- versions of these that would be used with the mat-table but I figured that there was no harm in making the cdk version of this compatible with the mat table as well in case people have their own ideas about how it should be styled.

Do you think that warrants a separate demo now or can it wait until the mat version?

@kseamon kseamon force-pushed the popover-edit-mvp branch 2 times, most recently from 813f514 to b567792 Compare March 21, 2019 18:41
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

I got about halfway through, have to run to a meeting now. I'll try to finish afterwards.

FYI if you respond to comments on the "Files changed" tab in GitHub, you can batch your responses instead of sending one email per reply

src/cdk-experimental/popover-edit/edit-events.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/edit-events.ts Outdated Show resolved Hide resolved
src/cdk-experimental/popover-edit/edit-events.ts Outdated Show resolved Hide resolved
* Returns an Observable that emits true when the specified element's cell
* is editing and false when not.
*/
editingCell(element: Element|EventTarget) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explicitly declare the return types for functions? Our docs generation tool isn't smart enough to infer the type.

* Returns an Observable that emits true when the specified element's cell
* is editing and false when not.
*/
editingCell(element: Element|EventTarget) {
Copy link
Member

Choose a reason for hiding this comment

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

For a follow-up PR: a lot of our APIs that take an element commonly accept ElementRef | Element

src/cdk-experimental/popover-edit/lens-directives.ts Outdated Show resolved Hide resolved
'(keydown.enter)': 'onEnter(true)',
'(keyup.enter)': 'onEnter(false)',
'(keyup.escape)': 'onEscape()',
'(document:click)': 'onDocumentClick($event)',
Copy link
Member

Choose a reason for hiding this comment

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

Could these handlers be named for what they do rather than when they're called?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some of the names are still not that descriptive (not sure how to describe what was formerly "onSubmit", really), but gave it a try.

src/cdk-experimental/popover-edit/polyfill.ts Show resolved Hide resolved
@kseamon kseamon force-pushed the popover-edit-mvp branch 2 times, most recently from a12027c to 48fcbee Compare March 29, 2019 20:34
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

I tried it out locally and found a few weird things:

  • Using the keyboard to trigger the "Close" button seems to close it and then immediately re-open ("Confirm" works, though)
  • Hovering over the rows in the examples is super jumpy; could that be tamed with some css?

*/

/** Selector for finding table cells. */
export const CELL_SELECTOR = '.cdk-cell, .mat-cell, td';
Copy link
Member

Choose a reason for hiding this comment

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

Not a concern for now, but before this exits experimental we'd want to remove any references to "mat" from the cdk package, whatever that would mean here. Might want to add a TODO

Copy link
Collaborator Author

@kseamon kseamon Apr 1, 2019

Choose a reason for hiding this comment

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

Longer term, the thing to do is probably to make that selector customizable via some DI config.

I included mat in there on the off chance someone would want to have a more stylistically unopinionated edit for their mat table than what MatPopoverEdit will be.

Copy link
Member

Choose a reason for hiding this comment

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

Selectors have to be completely static because they're resolved at compile time into generated code. We'd have to do something like creating a child class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is that true for this case where it's applying the selector imperatively?

Copy link
Member

Choose a reason for hiding this comment

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

Nvm, I didn't follow-through on how it was being used.

import {EditEvents} from './edit-events';

/**
* Service used for communication between the form within the edit lens and the
Copy link
Member

Choose a reason for hiding this comment

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

I would just remove the word "Service" from the description

src/cdk-experimental/popover-edit/table-directives.ts Outdated Show resolved Hide resolved
@kseamon kseamon force-pushed the popover-edit-mvp branch 3 times, most recently from d998e7a to 615d401 Compare April 1, 2019 15:39
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Apr 1, 2019
@jelbourn jelbourn added target: patch This PR is targeted for the next patch release P2 The issue is important to a large percentage of users, with a workaround pr: merge safe labels Apr 1, 2019
@mmalerba mmalerba merged commit 457ff28 into angular:master Apr 3, 2019
@NehalDamania
Copy link

Is there any link for the demo?

@kseamon
Copy link
Collaborator Author

kseamon commented Apr 12, 2019

Since the feature is still experimental, the demo is not part of the material.angular.io demo site yet. You can clone the repository and run gulp serve:devapp to see it.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants