yangzhang75 commented on code in PR #8839:
URL: https://github.com/apache/texera/pull/8839#discussion_r4445529406


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -1006,22 +1042,44 @@ export class WorkflowFormComponent implements OnInit, 
OnDestroy {
     // The schema's own title ("Attributes", "Limit", "File") -- the reader's 
title when unnamed.
     // Falls back to this, not the lower-camel key ("fileName"), which would 
read inconsistently.
     const schemaLabel = (source.props?.label as string) || binding.propertyKey;
-    field.key = binding.id;
+    // The field keeps the property's own key, as on the operator property 
panel: a widget that
+    // reaches a sibling or itself by key (the HuggingFace picker resets 
`modelId` and its
+    // task-scoped siblings on a task change) must find the same controls and 
model keys here.
     field.props = {
       ...(field.props ?? {}),
       label: binding.displayName || schemaLabel,
     };

Review Comment:
   `field` is `cloneDeep(source)`, and `source` is the formly child found by 
`child.key === binding.propertyKey` a few lines up, so the key is already the 
property's; assigning it again would be a no-op. The spec pins it: "renders a 
healthy input as a real formly field keyed by its property, as the panel does" 
asserts `fields[0].key` is `"n_hvg"`. No change.



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -563,6 +563,32 @@ export class WorkflowFormComponent implements OnInit, 
OnDestroy {
    */
   @HostListener("focusout")
   public onFocusOut(): void {
+    this.flushHeldRebuild();
+  }
+
+  /**
+   * A click or a key also ends a hold, because a focus change is not the only 
thing that does:
+   * closing an nz-select leaves the focus in its search box (ng-zorro 
re-focuses it), so no focusout
+   * fires, and a rebuild held while the list was open would have waited for 
an unrelated event
+   * (Copilot on #8839). The same later() re-check as below decides it after 
the current tick, by
+   * when the dropdown has lost its open class.
+   *
+   * The click is listened for on the document, not on this host. A dropdown's 
options are drawn in
+   * the CDK's overlay container, a sibling of the whole app rather than a 
descendant of this page,
+   * so the click that picks one -- or that picks the option already chosen, 
which changes no value
+   * and moves no focus -- never bubbles through here (Copilot). A click 
anywhere else ends the hold
+   * for the same reason a focusout does: the reader is no longer typing into 
the card. The handler
+   * returns at once unless a rebuild is actually held. Keys stay on the host: 
what is typed goes
+   * into controls this page owns (nz-select keeps its search box in the 
trigger, not the overlay),
+   * and a document-wide key listener would run on every keystroke in the 
workspace.
+   */
+  @HostListener("document:click")
+  @HostListener("keyup")
+  public onInteraction(): void {
+    this.flushHeldRebuild();
+  }
+
+  private flushHeldRebuild(): void {
     if (this.rebuildDeferred) {
       this.later(() => {
         if (this.rebuildDeferred) {

Review Comment:
   Done: `flushHeldRebuild` is single-flight now, with a `flushQueued` flag the 
callback clears. A burst of keys queues one re-check; a spec asserts five 
interactions queue one `later` and run the held rebuild once, and that the next 
hold is re-checked again. (f4ea02e80)



##########
frontend/src/app/workspace/service/form-binding/form-binding.service.ts:
##########
@@ -209,13 +209,23 @@ export class FormBindingService {
    * why a run started from either one behaves identically.
    */
   public writeValue(binding: FormFieldBinding, value: unknown): void {
-    const operator = this.getOperator(binding.operatorID);
+    this.writeProperties(binding.operatorID, { [binding.propertyKey]: value });
+  }
+
+  /**
+   * Write several properties of one operator at once, over its current ones: 
what a card's widget
+   * changed, which is the bound property and whatever siblings it touches the 
way it does on the
+   * operator property panel (the HuggingFace picker resets the task-scoped 
fields on a task
+   * change). One edit, as the panel makes one.
+   */
+  public writeProperties(operatorID: string, patch: Record<string, unknown>): 
void {
+    const operator = this.getOperator(operatorID);
     if (!operator) {
       return;
     }
-    this.workflowActionService.setOperatorProperty(binding.operatorID, {
+    this.workflowActionService.setOperatorProperty(operatorID, {
       ...operator.operatorProperties,
-      [binding.propertyKey]: value,
+      ...patch,
     });

Review Comment:
   Object spread does not reach the `__proto__` setter: `{...a, ...b}` defines 
an own property named `__proto__` and leaves `Object.prototype` untouched; only 
the literal form `{__proto__: x}` sets a prototype. The keys merged here come 
from the operator's schema and the card's own widget, not from imported 
content. No change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • Re: [PR] fix(workflow-form): le... yangzhang75 (via GitHub) via notifications

Reply via email to