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

Fixed an issue where it was not possible to programmatically set the value for dnn-autocomplete #1237

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
481 changes: 249 additions & 232 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ export const DnnToggle = /*@__PURE__*/createReactComponent<JSX.DnnToggle, HTMLDn
export const DnnTreeviewItem = /*@__PURE__*/createReactComponent<JSX.DnnTreeviewItem, HTMLDnnTreeviewItemElement>('dnn-treeview-item');
export const DnnVerticalOverflowMenu = /*@__PURE__*/createReactComponent<JSX.DnnVerticalOverflowMenu, HTMLDnnVerticalOverflowMenuElement>('dnn-vertical-overflow-menu');
export const DnnVerticalSplitview = /*@__PURE__*/createReactComponent<JSX.DnnVerticalSplitview, HTMLDnnVerticalSplitviewElement>('dnn-vertical-splitview');
export const TestForm = /*@__PURE__*/createReactComponent<JSX.TestForm, HTMLTestFormElement>('test-form');
13 changes: 0 additions & 13 deletions packages/stencil-library/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,6 @@ export namespace Components {
*/
"splitterWidth": number;
}
interface TestForm {
}
}
export interface DnnAutocompleteCustomEvent<T> extends CustomEvent<T> {
detail: T;
Expand Down Expand Up @@ -1277,12 +1275,6 @@ declare global {
prototype: HTMLDnnVerticalSplitviewElement;
new (): HTMLDnnVerticalSplitviewElement;
};
interface HTMLTestFormElement extends Components.TestForm, HTMLStencilElement {
}
var HTMLTestFormElement: {
prototype: HTMLTestFormElement;
new (): HTMLTestFormElement;
};
interface HTMLElementTagNameMap {
"dnn-autocomplete": HTMLDnnAutocompleteElement;
"dnn-button": HTMLDnnButtonElement;
Expand Down Expand Up @@ -1311,7 +1303,6 @@ declare global {
"dnn-treeview-item": HTMLDnnTreeviewItemElement;
"dnn-vertical-overflow-menu": HTMLDnnVerticalOverflowMenuElement;
"dnn-vertical-splitview": HTMLDnnVerticalSplitviewElement;
"test-form": HTMLTestFormElement;
}
}
declare namespace LocalJSX {
Expand Down Expand Up @@ -2080,8 +2071,6 @@ declare namespace LocalJSX {
*/
"splitterWidth"?: number;
}
interface TestForm {
}
interface IntrinsicElements {
"dnn-autocomplete": DnnAutocomplete;
"dnn-button": DnnButton;
Expand Down Expand Up @@ -2110,7 +2099,6 @@ declare namespace LocalJSX {
"dnn-treeview-item": DnnTreeviewItem;
"dnn-vertical-overflow-menu": DnnVerticalOverflowMenu;
"dnn-vertical-splitview": DnnVerticalSplitview;
"test-form": TestForm;
}
}
export { LocalJSX as JSX };
Expand Down Expand Up @@ -2176,7 +2164,6 @@ declare module "@stencil/core" {
*/
"dnn-vertical-overflow-menu": LocalJSX.DnnVerticalOverflowMenu & JSXBase.HTMLAttributes<HTMLDnnVerticalOverflowMenuElement>;
"dnn-vertical-splitview": LocalJSX.DnnVerticalSplitview & JSXBase.HTMLAttributes<HTMLDnnVerticalSplitviewElement>;
"test-form": LocalJSX.TestForm & JSXBase.HTMLAttributes<HTMLTestFormElement>;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Prop, State, Event, Element, h, Host, EventEmitter, Method, AttachInternals, Listen } from '@stencil/core';
import { Component, Prop, State, Event, Element, h, Host, EventEmitter, Method, AttachInternals, Listen, Watch } from '@stencil/core';
import { DnnAutocompleteSuggestion, NeedMoreItemsEventArgs } from './types';
import { Debounce } from '../../utilities/debounce';

Expand Down Expand Up @@ -105,6 +105,14 @@ export class DnnAutocomplete {
@State() positionInitialized = false;
@State() lastScrollTop = 0;
@State() displayValue: string = "";

@Watch("value")
handleValueChange(newValue: string) {
this.displayValue = newValue;

// Find the index of the selected item
this.selectedIndex = this.suggestions.findIndex(s => s.value === newValue);
}

/** attacth the internals for form validation */
@AttachInternals() internals: ElementInternals;
Expand Down
28 changes: 0 additions & 28 deletions packages/stencil-library/src/components/test-form/readme.md

This file was deleted.

This file was deleted.

76 changes: 0 additions & 76 deletions packages/stencil-library/src/components/test-form/test-form.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/stencil-library/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
</style>
</head>
<body>
<test-form></test-form>
<h1>Dnn HTML custom elements</h1>
<ul>
<li><a href="#dnn-autocomplete">dnn-autocomplete</a></li>
Expand Down
Loading