-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(lit): update Slider display value on user input #1022
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ import { customElement, property } from "lit/decorators.js"; | |
| import { Root } from "./root.js"; | ||
| import { A2uiMessageProcessor } from "@a2ui/web_core/data/model-processor"; | ||
| import * as Primitives from "@a2ui/web_core/types/primitives"; | ||
| import * as Types from "@a2ui/web_core/types/types"; | ||
| import { classMap } from "lit/directives/class-map.js"; | ||
| import { styleMap } from "lit/directives/style-map.js"; | ||
| import { structuralStyles } from "./styles.js"; | ||
|
|
@@ -62,24 +61,10 @@ export class Slider extends Root { | |
| ]; | ||
|
|
||
| #setBoundValue(value: string) { | ||
| if (!this.value || !this.processor) { | ||
| if (!this.value || !("path" in this.value) || !this.value.path) { | ||
| return; | ||
| } | ||
|
|
||
| if (!("path" in this.value)) { | ||
| return; | ||
| } | ||
|
|
||
| if (!this.value.path) { | ||
| return; | ||
| } | ||
|
|
||
| this.processor.setData( | ||
| this.component, | ||
| this.value.path, | ||
| value, | ||
| this.surfaceId ?? A2uiMessageProcessor.DEFAULT_SURFACE_ID | ||
| ); | ||
| this.updateBoundData(this.value.path, value); | ||
| } | ||
|
Comment on lines
63
to
68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a great fix for the slider value update issue. However, I noticed that there are no new tests included with this change. The repository style guide requires tests for code changes. Adding a regression test for this bug would be valuable to ensure it doesn't reappear in the future. Could you please add a test that covers this scenario? References
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no existing test infrastructure for v0.8 UI components in the Lit renderer, |
||
|
|
||
| #renderField(value: string | number) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved readability, you could consider extracting the path into a variable first, then checking its validity. This would make the intent of the code clearer at a glance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered this, but the current pattern (guard clause with early return) is consistent with how all other interactive components handle path validation (
checkbox.ts,datetime-input.ts,text-field.ts). Changing it here would make the Slider inconsistent with the rest. I'd rather keep it aligned.