Fixed memory leak and enhance KupTheme support#2871
Merged
Conversation
Bind KupBox click handler to the instance to avoid repeated binds. Overhaul KupDataTable focus and cell lookup: add #lastFocusedCellElement, use data-row-id attributes, and introduce helpers (#getRowFromElement, #getCellFromElement, #getFCellProps, #getRenderedCellElement) to resolve rows/cells from DOM elements. Persist/restore last focused cell element after render, update horizontal/vertical navigation to use the element reference, and set kup-get-cell-props to use a provided getCellProps closure. Update FCell declarations to accept getCellProps and FCell implementation to call it; improve input value extraction with getInputValueFromEvent and use that in events. Remove reliance on serialized data-cell objects in DOM and switch to dataset-based lookups. In KupTheme, add optional support for Constructable StyleSheets: cache shared sheets, adopt them into component shadow roots for supported tags, update shared sheets on theme changes, and refactor style composition (introduce getSharedStyle and updated setKupStyle) to use the new mechanism when available.
Expanded the KupTheme.adoptedStyleSheetsTargets set to include a large list of KUP custom elements (e.g. KUP-ACCORDION, KUP-BUTTON, KUP-CARD, KUP-DATA-TABLE, KUP-FORM, KUP-IMAGE, KUP-TREE, etc.). This allows the manager to apply shared CSS via adoptedStyleSheets to these components' shadow roots, ensuring consistent theming across more components.
lucafoscili
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces improvements to event listener management in
kup-boxand adds enhanced support for Constructable StyleSheets in thekup-thememanager. The most significant changes focus on memory leak prevention for event listeners and optimizing theme/style management for web components that support adopted style sheets.Event Listener Management Improvements:
clickFunctionis bound and stored inkup-boxby introducing a dedicated#boundClickFunctionproperty, ensuring the same function reference is used for both adding and removing the event listener. This prevents potential memory leaks and ensures proper cleanup. [1] [2] [3]Constructable StyleSheets and Theme Management Enhancements:
adoptedStyleSheetsTargets) inkup-theme, enabling more efficient and modern style management for supported browsers.sharedSheetsmap and theupdateSharedSheetsmethod, ensuring styles are efficiently reused and updated across components. [1] [2] [3]setKupStylemethod to use Constructable StyleSheets when possible, improving performance and encapsulation for supported components. The method now distinguishes between components that support adopted style sheets and those that do not, applying styles accordingly. [1] [2]getSharedStylehelper to centralize the logic for combining global, theme, and component-specific styles. [1] [2]