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

[InputBase] Improve documentation for custom inputComponent #16399

Merged
merged 12 commits into from
Jul 16, 2019

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Jun 27, 2019

Closes #16037

Turns out we already document it but are not very explicit about it.

@eps1lon eps1lon added docs Improvements or additions to the documentation component: InputBase labels Jun 27, 2019
docs/static/_redirects Outdated Show resolved Hide resolved
const wrapper = mount(<InputBase inputComponent={BadInputComponent} />);
assert.throws(
// simulating e.g. react-stripe-elements that hides the event target
() => wrapper.find('input').simulate('change', { target: null }),
Copy link
Member Author

Choose a reason for hiding this comment

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

aside: no idea why this simulate is StrictMode compatible but fireEvent.change doesn't even register. Probably missing something obvious about change events.

@mui-pr-bot
Copy link

mui-pr-bot commented Jun 27, 2019

@material-ui/core: parsed: +0.07% , gzip: +0.15%

Details of bundle changes.

Comparing: a1ffac5...c22a2a3

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core +0.07% 🔺 +0.15% 🔺 327,763 327,990 90,314 90,449
@material-ui/core/Paper 0.00% 0.00% 68,477 68,477 20,407 20,407
@material-ui/core/Paper.esm 0.00% 0.00% 61,761 61,761 19,190 19,190
@material-ui/core/Popper 0.00% 0.00% 28,942 28,942 10,407 10,407
@material-ui/core/Textarea 0.00% 0.00% 5,505 5,505 2,365 2,365
@material-ui/core/TrapFocus 0.00% 0.00% 3,753 3,753 1,576 1,576
@material-ui/core/styles/createMuiTheme 0.00% 0.00% 16,160 16,160 5,813 5,813
@material-ui/core/useMediaQuery 0.00% 0.00% 2,595 2,595 1,104 1,104
@material-ui/lab 0.00% 0.00% 138,027 138,027 42,562 42,562
@material-ui/styles 0.00% 0.00% 51,887 51,887 15,384 15,384
@material-ui/system 0.00% 0.00% 15,576 15,576 4,432 4,432
Button 0.00% 0.00% 81,161 81,161 24,779 24,779
Modal 0.00% 0.00% 14,551 14,551 5,102 5,102
Portal 0.00% 0.00% 3,471 3,471 1,573 1,573
Slider 0.00% 0.00% 75,100 75,100 23,309 23,309
colorManipulator 0.00% 0.00% 3,904 3,904 1,543 1,543
docs.landing 0.00% 0.00% 54,338 54,338 13,762 13,762
docs.main +0.04% 🔺 +0.06% 🔺 647,863 648,103 204,220 204,343
packages/material-ui/build/umd/material-ui.production.min.js +0.08% 🔺 +0.17% 🔺 300,178 300,405 86,044 86,190

Generated by 🚫 dangerJS against c22a2a3

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

nice :)

docs/static/_redirects Outdated Show resolved Hide resolved
@eps1lon
Copy link
Member Author

eps1lon commented Jun 28, 2019

@material-ui/core: parsed: +0.07% , gzip: +0.16%

Did some testing before this PR and it was not useful to minify the error messages. Might be at some point though. Should keep an eye on it.

import { expect } from 'chai';
import { getContents } from './parseMarkdown';

describe('parseMarkdown', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the kind of test where I would prefer fixtures + snapshots but it's not worth it to set this up for one test. If this test becomes an issue (breaks, readability etc) we can revisit.

@@ -37,7 +37,7 @@ export const demoRegexp = /^"demo": "(.*)"/;
export function getContents(markdown) {
return markdown
.replace(headerRegExp, '') // Remove header information
.split(/^{{|}}$/gm) // Split markdown into an array, separating demos
.split(/^{{("demo":[^}]*)}}$/gm) // Split markdown into an array, separating demos
Copy link
Member Author

Choose a reason for hiding this comment

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

@eps1lon eps1lon requested a review from oliviertassinari June 28, 2019 09:13
@eps1lon
Copy link
Member Author

eps1lon commented Jun 28, 2019

I'm so tired of browser tests. Icing this until this is important.

@oliviertassinari oliviertassinari force-pushed the docs/stripe-integration branch 2 times, most recently from 286a4d2 to b32cde3 Compare July 13, 2019 22:48
);
let errorMessage = null;
try {
handleRef.current.trigger();
Copy link
Member

Choose a reason for hiding this comment

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

fireEvent.change needs a non-null value to trigger the handler.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. That was the part I was missing about change events. Got a simpler idea though which is closer to how react-stripe-elements works.

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue was less about how change events are created but rather about error handling in react. I'm unable to catch errors from event handlers in our browser tests.

@eps1lon eps1lon requested a review from oliviertassinari July 14, 2019 13:21
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Great :)

@eps1lon eps1lon merged commit 6dc4ca3 into mui:master Jul 16, 2019
@eps1lon eps1lon deleted the docs/stripe-integration branch July 16, 2019 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to use react-stripe-js?
3 participants