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
Conversation
9aa4c30
to
46ec7c0
Compare
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.
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 of
mat`. How do you want to provide that selector to the underlying logic so that it knows what to look out for?
readonly hovering = new Subject<Element|null>(); | ||
readonly mouseMove = new Subject<Element|null>(); | ||
|
||
protected currentlyEditing: Element|null = null; |
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 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?
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 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.
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? |
813f514
to
b567792
Compare
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 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
* Returns an Observable that emits true when the specified element's cell | ||
* is editing and false when not. | ||
*/ | ||
editingCell(element: Element|EventTarget) { |
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.
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) { |
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.
For a follow-up PR: a lot of our APIs that take an element commonly accept ElementRef | Element
'(keydown.enter)': 'onEnter(true)', | ||
'(keyup.enter)': 'onEnter(false)', | ||
'(keyup.escape)': 'onEscape()', | ||
'(document:click)': 'onDocumentClick($event)', |
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.
Could these handlers be named for what they do rather than when they're called?
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.
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/material-examples/cdk-popover-edit-cdk-table/cdk-popover-edit-cdk-table-example.css
Outdated
Show resolved
Hide resolved
a12027c
to
48fcbee
Compare
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 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'; |
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.
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
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.
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.
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.
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.
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.
Is that true for this case where it's applying the selector imperatively?
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.
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 |
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 would just remove the word "Service" from the description
src/material-examples/cdk-popover-edit-cdk-table/cdk-popover-edit-cdk-table-example.html
Outdated
Show resolved
Hide resolved
d998e7a
to
615d401
Compare
615d401
to
16ce33a
Compare
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.
LGTM
Is there any link for the demo? |
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. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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.