Skip to content

Fix/eui migrate class to function components#9618

Open
toffku wants to merge 3 commits intoelastic:mainfrom
toffku:fix/eui-migrate-class-to-function-components
Open

Fix/eui migrate class to function components#9618
toffku wants to merge 3 commits intoelastic:mainfrom
toffku:fix/eui-migrate-class-to-function-components

Conversation

@toffku
Copy link
Copy Markdown

@toffku toffku commented Apr 27, 2026

Summary

  • What: Migrated EuiFormControlLayoutIcons from class to function component. Converted class methods (renderCustomIcon, renderLoadingSpinner, renderClearButton, renderInvalidIcon, renderDropdownIcon) into helper functions.

  • Why: Fixes [EuiFormControlLayoutIcons] Migrate from class to function components #9461

  • How:

    • Removed Component import, kept React import
    • Converted class declaration to arrow function component with destructured props
    • Extracted render methods as standalone functions that accept parameters instead of reading from this.props

API Changes

component / parent prop / child change description
None None None None

Screenshots

Before After
{Before image} {After image}

Impact Assessment

Note: Most PRs should be tested in Kibana to help gauge their Impact before merging.

  • 🔴 Breaking changes — What will break? How many usages in Kibana/Cloud UI are impacted?
  • 💅 Visual changes — May impact style overrides; could require visual testing. Explain and estimate impact.
  • 🧪 Test impact — May break functional or snapshot tests (e.g., HTML structure, class names, default values).
  • 🔧 Hard to integrate — If changes require substantial updates to Kibana, please stage the changes and link them here.

Impact level: 🟢 None

Release Readiness

  • Documentation: {link to docs page(s)}
  • Figma: {link to Figma or issue}
  • Migration guide: {steps or link, for breaking/visual changes or deprecations}
  • Adoption plan (new features): {link to issue/doc or outline who will integrate this and where}

QA instructions for reviewer

Checklist before marking Ready for Review

Reviewer checklist

  • Approved Impact Assessment — Acceptable to merge given the consumer impact.
  • Approved Release Readiness — Docs, Figma, and migration info are sufficient to ship.

Copilot AI review requested due to automatic review settings April 27, 2026 19:04
@toffku toffku requested a review from a team as a code owner April 27, 2026 19:04
@github-actions
Copy link
Copy Markdown

👋 Since this is a community submitted pull request, a Buildkite build has not been started automatically. Would an Elastic organization member please verify the contents of this pull request and kick off a build manually?

@github-actions github-actions Bot added the community contribution (Don't delete - used for automation) label Apr 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates EuiFormControlLayoutIcons from a stateless class component to a function component to address #9461, keeping render behavior the same while simplifying the implementation.

Changes:

  • Converted EuiFormControlLayoutIcons from class extends Component to a function component with destructured props/defaults
  • Extracted former class render methods into module-level helper functions (renderCustomIcon, renderLoadingSpinner, etc.)
  • Updated React import to remove the unused Component import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@weronikaolejniczak weronikaolejniczak added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Apr 28, 2026
@elasticmachine
Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

@elasticmachine
Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

@weronikaolejniczak weronikaolejniczak self-requested a review May 4, 2026 16:28
Comment on lines +109 to +133
const renderCustomIcon = (
icon: EuiFormControlLayoutIconsProps['icon'],
isDisabled: EuiFormControlLayoutIconsProps['isDisabled']
) => {
if (!icon) {
return null;
}

renderDropdownIcon() {
const { isDropdown, isDisabled } = this.props;

if (!isDropdown) {
return null;
}
// Normalize the icon to an object if it's a string.
const iconProps: IconShape = isIconShape(icon)
? icon
: {
type: icon,
};
const { ref: iconRef, side, ...iconRest } = iconProps;

return (
<EuiFormControlLayoutCustomIcon
size="m"
disabled={isDisabled}
iconRef={iconRef}
{...iconRest}
/>
);
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@toffku It's absolutely okay for the purposes of the class to function migration to simply raise these render functions to module level and call it a day. But a more idiomatic approach here would be to make them into components.

E.g.

Suggested change
const renderCustomIcon = (
icon: EuiFormControlLayoutIconsProps['icon'],
isDisabled: EuiFormControlLayoutIconsProps['isDisabled']
) => {
if (!icon) {
return null;
}
renderDropdownIcon() {
const { isDropdown, isDisabled } = this.props;
if (!isDropdown) {
return null;
}
// Normalize the icon to an object if it's a string.
const iconProps: IconShape = isIconShape(icon)
? icon
: {
type: icon,
};
const { ref: iconRef, side, ...iconRest } = iconProps;
return (
<EuiFormControlLayoutCustomIcon
size="m"
disabled={isDisabled}
iconRef={iconRef}
{...iconRest}
/>
);
};
const CustomIcon = ({ icon, isDisabled }: {
icon: EuiFormControlLayoutIconsProps['icon'],
isDisabled: EuiFormControlLayoutIconsProps['isDisabled']
}) => {
if (!icon) return null;
// Normalize the icon to an object if it's a string.
const iconProps: IconShape = isIconShape(icon)
? icon
: { type: icon };
const { ref: iconRef, side, ...iconRest } = iconProps;
return (
<EuiFormControlLayoutCustomIcon
size="m"
disabled={isDisabled}
iconRef={iconRef}
{...iconRest}
/>
);
};

and then in EuiFormControlLayoutIcons render: <CustomIcon icon={icon} isDisabled={isDisabled} />

Copy link
Copy Markdown
Contributor

@weronikaolejniczak weronikaolejniczak left a comment

Choose a reason for hiding this comment

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

I have just one comment that is very straightforward to address. Otherwise, we're good to go! Thank you for contributing, @toffku 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EuiFormControlLayoutIcons] Migrate from class to function components

4 participants