Skip to content

Fix multiple class components to not regenerate IDs on rerender#5201

Merged
cee-chen merged 5 commits intoelastic:masterfrom
cee-chen:use-generated-html-id-3
Sep 21, 2021
Merged

Fix multiple class components to not regenerate IDs on rerender#5201
cee-chen merged 5 commits intoelastic:masterfrom
cee-chen:use-generated-html-id-3

Conversation

@cee-chen
Copy link
Copy Markdown
Contributor

@cee-chen cee-chen commented Sep 20, 2021

Summary

Parent PR: #5195

  • Class components fixed (before/after screencaps in individual code comments below)
    • EuiAccordion
    • EuiComboBox
    • EuiFilePicker
    • EuiPopover
    • EuiSideNav
  • Class components that did not need to be fixed (static IDs saved to state or class var)
    • EuiCodeEditor
    • EuiFormRow
    • EuiDualRange
    • EuiRange
    • EuiOutsideClickDetector
    • EuiSelectable
    • EuiTabbedContent
    • EuiToolTip
    • EuiTreeView
  • Class components left alone:
    • EuiIcon - I wasn't sure how to interpret how the titleId was being used and I couldn't find an example of it in our docs

Checklist

QA screencaps in comments below

Single changelog entry will be made in #5195

@cee-chen cee-chen added skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) tech debt labels Sep 20, 2021
let icon;
let iconButton;
const buttonId = buttonProps?.id ?? htmlIdGenerator()();
const buttonId = buttonProps?.id ?? this.generatedId;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before:

accordion_before

After:

accordion_after

'To exit the list of choices, press Escape.';

removeOptionMessageId = htmlIdGenerator()();
removeOptionMessageId = rootId('removeOptionMessage');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before (ID rerenders between span appearing/disappearing):

combobox_before

After (ID stays the same between span renders):

combobox_after

if (id) {
promptId = `${id}-filePicker__prompt`;
}
const promptId = `${id || this.generatedId}-filePicker__prompt`;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before:

file_picker_before

After:

file_picker_after

focusTrapScreenReaderText = (
<EuiScreenReaderOnly>
<p id={descriptionId}>
<p id={this.descriptionId}>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before (description ID rerenders between popover show/hide toggles):

popover_before

This one is super tough to see because the ID rerender happens in the short split second before the popover unrenders itself completely from the DOM, but you can from the ID Ctrl+F that the ID is changing between each popover render/rerender (as opposed to the fix below, where the ID remains static between show/hide states).

After (ID remains static between show/hide):

popover_after

In the "after", I can save the popover description ID and ctrl+F for it again after the popover has been re-shown to find the same ID.

)
);
const sideNavContentId = htmlIdGenerator('euiSideNavContent')();
const sideNavContentId = this.generateId('content');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before:

side_nav_before

After:

side_nav_after

@cee-chen cee-chen marked this pull request as ready for review September 20, 2021 18:45
@kibanamachine
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Thanks again, @constancecchen!

@cee-chen
Copy link
Copy Markdown
Contributor Author

Thanks for the speedy reviews @thompsongl!

@cee-chen cee-chen merged commit 987d269 into elastic:master Sep 21, 2021
@cee-chen cee-chen deleted the use-generated-html-id-3 branch September 21, 2021 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants