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

Bugfix: scope CSS of input elements #2589

Merged
merged 11 commits into from
Jul 13, 2023
Merged

Bugfix: scope CSS of input elements #2589

merged 11 commits into from
Jul 13, 2023

Conversation

KoolADE85
Copy link
Contributor

@KoolADE85 KoolADE85 commented Jul 6, 2023

This PR adds a class name to input elements so that the CSS for those inputs can be contained within the dash app and not affect non-Dash inputs.

Contributor Checklist

  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

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

💃 Looks good.

@@ -54,15 +54,6 @@
],
"description": "Indicates whether controls in this form can by default have their values automatically completed by the browser."
},
"autoFocus": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

weird, autoFocus disappeared from the reference docs? Yes: mdn/content#27734 - the PR mentions this page: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes which (a) we don't inspect at all during the build process, (b) implies autoFocus applies to a lot more than just these four element types.

This seems like it would be a breaking change - I don't actually know if this attribute works in a Dash app, we may be adding our elements too late in the page lifecycle for this to be honored, but even if it doesn't work we shouldn't break an app that already includes it.

More broadly, I don't like the fact that in every PR our tests are at the mercy of MDN's changes, we should really make "update the HTML spec from MDN" an optional thing that we do occasionally, maybe when we're updating dependencies or maybe even less frequently. @T4rk1n thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should change the generation to be more stable. The test allow us to see there is change, but maybe it should be a CI job that run once a month or so and create a PR if there is change.

An alternative could be to change the scraper and instead use the React types that are contained in JSX.IntrinsicElements. That would change only when the react version is changed and should more stable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the changes to attributes.json don't actually need to be committed now. I reverted them, and the build/tests still function without them.
However, the change to extract-elements.js does need to be here in order to complete a build.
So I'd propose decoupling attributes.json from this PR, and we can think about this as a separate fix.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we'll need to address this prior to a release regardless, as that process will call the full rebuild. But yeah for the sake of this PR we can ignore it.

Comment on lines 77 to +79
{...omit(
[
'className',
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI we use this a lot but I'd love to get rid of this ...omit pattern pretty much wherever we use it. It causes various problems, like I bet we're currently improperly forwarding persistence/persistence_type/persisted_props here, and some other places we still forward loading_state so the DOM ends up with `loading_state="[object Object]". Instead we should figure out which props we DO want and pick them, or just individually forward them. I thought I had made an issue for this but not seeing it now 🤔

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃 This looks great, please either before or after merging make new issues for both removing omit for prop forwarding and for decoupling our everyday build process from MDN

@KoolADE85
Copy link
Contributor Author

woman_dancing This looks great, please either before or after merging make new issues for both removing omit for prop forwarding and for decoupling our everyday build process from MDN

Done! #2600 #2601

@KoolADE85 KoolADE85 merged commit 1718ec0 into dev Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants