Skip to content

[refactor] extract state and logic from element.tsx into React parent component#26

Merged
divazbozz merged 4 commits intomainfrom
david/prod-137-tech-debt-web-component-refactoring
Feb 13, 2026
Merged

[refactor] extract state and logic from element.tsx into React parent component#26
divazbozz merged 4 commits intomainfrom
david/prod-137-tech-debt-web-component-refactoring

Conversation

@divazbozz
Copy link
Contributor

@divazbozz divazbozz commented Feb 13, 2026

PROD-137

refactor web component properly, see below for details

Changes

  • Create AddressSearchApp.tsx — new React parent component that absorbs all state management and business logic from element.tsx

    • 4 state variables (selection, externalAddressId, multipleUtilityResult, multipleAddressResults)
    • All handler functions (handleSelect, handleRedirect, handleUserSelectAddress, handleBack)
    • Modal portal rendering (SelectionModal via createPortal)
  • Simplify element.tsx from 241 → 114 lines (-53%) to a thin web component shell

    • Only handles: shadow DOM setup, attribute parsing, single createRoot, CustomEvent dispatching via callback props
  • Bug fixes included:

    • Fix createRoot called on every render — now created once in connectedCallback and reused
    • Fix broken disconnectedCallback — properly unmounts the stored root instead of creating a new one
    • Fix overlay wrapper leak — overlayWrapper is now removed from document.body on disconnect
    • Fix bootstrap() called every render — moved to connectedCallback, runs once
    • React state (input value, autocomplete cache) is now preserved across re-renders and modal transitions

Test

address selection + utility modal all good, interaction are good
image

image

@divazbozz divazbozz changed the title simplify elements.tsx and add AddressSearchApp [refactor] extract state and logic from element.tsx into React parent component Feb 13, 2026
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 6 additional findings.

Open in Devin Review

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

divazbozz and others added 2 commits February 12, 2026 19:56
…d root

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@divazbozz divazbozz requested a review from bkobelan February 13, 2026 02:08
Copy link
Contributor

@bkobelan bkobelan left a comment

Choose a reason for hiding this comment

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

so clean

@divazbozz divazbozz merged commit 418e117 into main Feb 13, 2026
1 check passed
@divazbozz divazbozz deleted the david/prod-137-tech-debt-web-component-refactoring branch February 13, 2026 04:53
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.

2 participants