Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

snackbar: dynamic open #708

Merged
merged 7 commits into from
Mar 19, 2019

Conversation

aluminick
Copy link
Contributor

added missing componentDidUpdate for dynamic opening

@codecov-io
Copy link

codecov-io commented Mar 1, 2019

Codecov Report

Merging #708 into rc0.11.0_real will decrease coverage by 0.02%.
The diff coverage is 66.66%.

Impacted file tree graph

@@                Coverage Diff                @@
##           rc0.11.0_real     #708      +/-   ##
=================================================
- Coverage          95.14%   95.12%   -0.03%     
=================================================
  Files                 73       73              
  Lines               2907     2913       +6     
  Branches             444      447       +3     
=================================================
+ Hits                2766     2771       +5     
  Misses                46       46              
- Partials              95       96       +1
Impacted Files Coverage Δ
packages/snackbar/index.tsx 95.65% <66.66%> (-1.18%) ⬇️

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 fcd480d...4a69f38. Read the comment docs.

if (prevProps.open !== open) {
if (open) {
this.foundation.open();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't you call this.foundation.close() on an else clause?

Copy link

Choose a reason for hiding this comment

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

Correct...we need the this.foundation.close(reason). I suspect we would also want a closedReason prop that gets passed to reason in the close method. I'm open to other ideas too.

Copy link
Contributor

Choose a reason for hiding this comment

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

we could use the prop with a default of the dismissed value from the mdc snackbar, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

that seems reasonable to have a default, but we would still need to be able to override it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lucasecdb sorry, my bad. Now I understand what you mean.

Copy link

Choose a reason for hiding this comment

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

The use case is if someone wants to programmatically close the snackbar before it automatically closes. I've attached a patch to add on to the screenshot tests.

snackbar.patch.zip

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@moog16 I've applied the patch. I didn't event know this thing exists. thanks :)
I just called foundation.close with an empty argument if open prop is false.

Copy link

Choose a reason for hiding this comment

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

Can you add another prop for the reason? I'm thinking something like:

const {reason} = this.props;
...
this.foundation.close(reason)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@moog16 Sure. Sorry for the late replies. I'll push the update you need in a moment.

@moog16
Copy link

moog16 commented Mar 1, 2019

fixes #707

Copy link

@moog16 moog16 left a comment

Choose a reason for hiding this comment

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

Please add a test case for the if/else

@@ -52,6 +52,13 @@ test('renders stacked actions', () => {
wrapper.unmount();
});

test('#componentDidUpdate calls foundation.open if props.open is true', () => {
Copy link

Choose a reason for hiding this comment

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

please add the opposite case for foundation.open = false

@moog16
Copy link

moog16 commented Mar 14, 2019

@aluminick just checking in to see what the status of this PR is.

@@ -38,6 +38,7 @@ export interface Props {
leading?: boolean;
stacked?: boolean;
open?: boolean;
reason?: string;
Copy link

Choose a reason for hiding this comment

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

@aluminick please add this prop to the readme

Copy link

@moog16 moog16 left a comment

Choose a reason for hiding this comment

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

@aluminick looks good - just need to the readme update and we'll be good to go

@moog16
Copy link

moog16 commented Mar 18, 2019

Update golden.json snackbar entry to 3da3c11708088eb563f403f808e0db4d45096e8a098700f95bfcfca13b1c2773

@moog16 moog16 changed the base branch from rc0.11.0 to rc0.11.0_real March 18, 2019 23:25
@moog16 moog16 merged commit 04fe2bf into material-components:rc0.11.0_real Mar 19, 2019
moog16 pushed a commit that referenced this pull request Mar 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants