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

[Docs] Replace Static HTML Element IDs Generated IDs (Layout Section) #5220

Merged
merged 21 commits into from
Oct 11, 2021

Conversation

breehall
Copy link
Contributor

@breehall breehall commented Sep 28, 2021

Summary

Updates any static HTML element IDs inside of EUI documentation with IDs generated by the useGeneratedHtmlId utility hook and htmlIdGenerator()() utility function. This change is based on Issue #4774 where it was reported that including multiple copies of the same code snippet can cause duplicate ID errors. While static IDs were removed, the existing generated IDs were standardized across relevant files.
Page-by-page review of the docs revealed that there are about 80 instances of HTML element IDs in the docs. Here is a document defining the pages and components affected by this change.

This PR is to handle generated ID changes within the Layout section of the docs

Before
With Static IDs

After
Static IDs Removed

Note
This started in PR 5114 and after team input, I'll be creating smaller PRs for each major section of the docs.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

breehall and others added 18 commits September 15, 2021 14:02
…Ds generated the htmlIdGenerator utility function
…l-htmlIdGenerator_docs

Merging in the latest code from Master
…Ds generated the useGeneratedHtmlId utility function
…eehall/eui into breehall-htmlIdGenerator_docs

Merging in the lastest code from the Master branch.
…generated the useGeneratedHtmlId utility function
…generated the useGeneratedHtmlId utility function
…generated the useGeneratedHtmlId utility function
…l-htmlIdGenerator_docs

Merging in the latest code from the Master branch
…generated the useGeneratedHtmlId utility function
…enerated the useGeneratedHtmlId utility function
…l-htmlIdGenerator_docs

Merging in the latest code from the Master branch
…l-htmlIdGenerator_docs

Merging in the latest code from teh Master branch
… use the useGeneratedHtmlId utility function
…l-htmlIdGenerator_docs

Merging in the latest code from Master
… use the useGeneratedHtmlId utility function
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5220/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5220/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

One thing to note, is that at some point we should really be combining all these imports to point directly to src instead of src/services or src/components because they end up as separate @elastic/eui import lines.

Question:
When should we determine whether to use the new hook or old ()() version? For example the loading state example has a button toggle that still uses htmlIdGenerator()()?

I Checked:

  • Accordions
    • Can you update the snippets that contain multiple accordions in the same snippet in them to also contain unique ids? Like this example uses the same constant name in both accordions, but it should probably just be accordionId1 and accordionId2. If they're separate snippets its ok to no be unique.
  • Flyout
  • Header
  • Popover
  • Modal
  • Resizable panel

…et_values.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5220/

@breehall
Copy link
Contributor Author

One thing to note, is that at some point we should really be combining all these imports to point directly to src instead of src/services or src/components because they end up as separate @elastic/eui import lines.

I agree. It looks like we have an open issue for this ( Issue #5104 ), so we can tackle it soon.

Question: When should we determine whether to use the new hook or old ()() version? For example the loading state example has a button toggle that still uses htmlIdGenerator()()?

I determined it based on the rule of hooks. Since useGeneratedHtmlId is a hook, it can't be placed outside of the scope of the component like htmlIdGenerator can. With this example specifically, I don't foresee a problem with simply moving the generator call and toggleButton array inside of the component. This was my thinking, but I'm welcome to ideas!

@cchaos
Copy link
Contributor

cchaos commented Sep 29, 2021

I agree

👍 😄

it can't be placed outside of the scope of the component

🤦‍♀️ I totally missed this (that it wasn't created inside the component). Makes sense to keep it outside then just for simplicity sake of this PR.

@cchaos
Copy link
Contributor

cchaos commented Oct 11, 2021

Hey @breehall , Is there more feedback you need on this PR? I've got some updates I need to push to the Accordion component and I know the docs I touched will conflict with this PR, so it might be good to get this one in first.

@breehall
Copy link
Contributor Author

@cchaos I don't believe so. This PR includes your previous feedback, so it should be ok to merge. I just hesitated because I didn't see an official approval on this. But if it looks good, I'll get this one merged 😊

@cchaos
Copy link
Contributor

cchaos commented Oct 11, 2021

I think there was still one more suggestion I provided about the accordions examples:

Can you update the snippets that contain multiple accordions in the same snippet in them to also contain unique ids? Like this example uses the same constant name in both accordions, but it should probably just be accordionId1 and accordionId2. If they're separate snippets its ok to not be unique.

Created unique IDs in the snapshots for the example components for accordions.
@breehall
Copy link
Contributor Author

@cchaos Sorry about that! I thought I had handled it, but it looks like it's updated now. Good catch!

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5220/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Awesome! LGTM!

@breehall breehall merged commit 9efb171 into elastic:master Oct 11, 2021
ym pushed a commit to ym/eui that referenced this pull request Oct 29, 2021
…elastic#5220)

* Revised element IDs within the Accordion section of src/docs to use IDs generated the htmlIdGenerator utility function

* Revised element IDs within the Accordion section of src/docs to use IDs generated the useGeneratedHtmlId utility function

* Revised element IDs within the Flyout section of src/docs to use IDs generated the useGeneratedHtmlId utility function

* Revised element IDs within the Header section of src/docs to use IDs generated the useGeneratedHtmlId utility function

* Revised element IDs within the Header section of src/docs to use IDs generated the useGeneratedHtmlId utility function

* Revised element IDs within the Header section of src/docs to use IDs generated the useGeneratedHtmlId utility function

* Revised element IDs within the Modal section of src/docs to use IDs generated the useGeneratedHtmlId utility function

* Test commit

* Revised element IDs within the Resizable Panel section of src/docs to use the useGeneratedHtmlId utility function

* Revised element IDs within the Resizable Panel section of src/docs to use the useGeneratedHtmlId utility function

* Revisions from PR

* Update src-docs/src/views/resizable_container/resizable_container_reset_values.js

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

* Update accordion_example.js

Created unique IDs in the snapshots for the example components for accordions.

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@breehall breehall deleted the breehall-htmlIdGenerator_docs_layout branch February 7, 2022 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants