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

refactor: make InputSuggestions a normal dynamic import #10510

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

vladitasev
Copy link
Contributor

@vladitasev vladitasev commented Jan 10, 2025

This change is a part of the component features rework which was made possible by the transition to TSX (since the templates themselves now bring the dependencies and the only responsibility of the features concept was dependency management, which is now obsolete for TSX-enabled components)

  • features are now normal ES6 modules or just extra templates and each component manages them the way it sees fit - there is no longer a framework-enforced features concept, ComponentFeature base class or features registry
  • Apps can still load the InputSuggestions.js module as before (nothing changed in this regard) and this will act as a "preload" and will simply skip the dynamic import in enableSuggestions later.
  • But if an app does not bundle InputSuggestions.js, and still tries to set showSuggestions = true, there will no longer be a console warning, but it will work by dynamically importing the feature and using it.

Inside Input.ts the Suggestions property is now managed state, because we want it to be invalidating (when the dynamic import is ready, and this.Suggestions is set, the ui5-input must invalidate for the suggestions template to be rendered)

Additionally, deleted some leftover commented test code:

// declare module "@ui5/webcomponents-base/jsx-runtime" {
// 	// eslint-disable-next-line @typescript-eslint/no-namespace
// 	namespace JSX {
// 		interface IntrinsicElements {
// 			"ui5-input": Input["_jsxProps"];
// 		}
// 	}
// }

Suggestions.i18nBundle = Input.i18nBundle;
this.Suggestions = new Suggestions(this, "suggestionItems", true, false);
};

// If the features is preloaded (the user manually imported InputSuggestions.js), it is already available on the constructor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix the typo (features -> feature) in another PR not to re-trigger the build just for that

@vladitasev vladitasev merged commit 241befa into main Jan 22, 2025
10 checks passed
@vladitasev vladitasev deleted the input-suggestions-feature-rework branch January 22, 2025 11:30
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.

2 participants