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


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.html:
##########
@@ -487,6 +487,64 @@ <h2>{{ instructionTitle || "How to use this" }}</h2>
       </div>
     </section>
 
+    <!-- The results this page can show, listed right under the preview since 
both are about the same
+         steps: one chip each, carrying the step's name and an eye. A reader 
with nothing to choose
+         from sees no section; an author always does, with the hint on how to 
add steps. The chips are
+         tracked by step, not by object: a change rebuilds the choices as new 
objects, and re-created
+         buttons would drop the keyboard focus from the chip just pressed. -->
+    <section
+      class="card respick"
+      *ngIf="authoring || resultChoices.length > 0">
+      <h3>Results shown here</h3>
+      <p>
+        {{ authoring ? "Click a name to look at that step; the eye sets 
whether its result shows for everyone. Until you
+        choose, every final step is on, and an earlier step needs its result 
view on the canvas first." : "Click a name
+        to bring its result to the top, and again to let the step go. The eye 
hides a result from your page only." }}
+      </p>
+      <div class="opts">
+        <!-- Two buttons in one chip: the name reaches the result (and the 
step it came from), the
+             eye decides whether it shows. Separate targets, so neither click 
has a second meaning
+             depending on a mode (#9033). -->
+        <div
+          class="pill"
+          *ngFor="let choice of resultChoices; trackBy: trackByChoice"
+          [class.on]="choice.shown"
+          [class.lead-result]="leadsResults(choice.operatorID)">
+          <!-- A hidden result has no card to bring to the top, so its name 
does nothing and does
+               not react to the pointer. Marked unavailable rather than 
disabled, so it keeps its
+               place in the tab order and says why instead of going silent -- 
the eye beside it is
+               live, and that is how the result comes back.
+               `aria-current` carries what the ring shows: which result is the 
one being looked at,
+               for a reader who does not see the ring. -->
+          <button
+            type="button"
+            class="pill-name"
+            [attr.aria-disabled]="!choice.shown"
+            [attr.aria-current]="leadsResults(choice.operatorID)"
+            [attr.title]="choice.shown ? null : 'Hidden. Turn its eye on to 
show this result.'"
+            (click)="onChoiceClick(choice)">
+            {{ choice.label }}
+          </button>
+          <button
+            type="button"
+            class="pill-eye"
+            [attr.aria-pressed]="choice.shown"
+            [attr.aria-label]="(choice.shown ? 'Hide ' : 'Show ') + 
choice.label"

Review Comment:
   Fixed. The name is constant now -- `Show <result>` with the state on 
`aria-pressed`, as on the label wrapper's eye, which carries a comment saying 
exactly this. The title still says which way it is ("Shown here" / "Hidden 
here") for a pointer. The rendered test asserts the constant name and both 
pressed states. (7cb53d068)



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.scss:
##########
@@ -1077,30 +1086,88 @@ $shell: #fafafa;
     gap: 8px;
   }
 
+  /* One result, two things to do with it: the name reaches it, the eye 
decides whether it shows.
+     Two buttons rather than one with a mode, so a click always means the same 
thing (#9033). They
+     share a border so the pair still reads as one chip. */
   .pill {
-    padding: 5px 12px;
+    display: inline-flex;
+    align-items: stretch;
     border-radius: 15px;
     font-size: 13px;
     border: 1px solid $border;
     background: #fff;
     color: $text-2;
-    cursor: pointer;
+    overflow: hidden;
 
-    &:hover {
-      border-color: $blue;
-      color: $blue;
+    button {
+      appearance: none;
+      border: 0;
+      background: none;
+      color: inherit;
+      font: inherit;
+      cursor: pointer;
+
+      &:focus-visible {
+        outline: 2px solid $blue;
+        outline-offset: -2px;
+      }
     }
 
-    &:focus-visible {
-      outline: 2px solid $blue;
-      outline-offset: 2px;
+    .pill-name {
+      padding: 5px 11px;
+
+      &:hover:not([aria-disabled="true"]) {
+        color: $blue;
+      }
+
+      /* Hidden: there is no card to bring to the top, so the name neither 
reacts nor invites. */
+      &[aria-disabled="true"] {
+        cursor: default;
+        opacity: 0.55;
+      }
+    }
+
+    /* Its own segment, with a rule between: a target to aim at rather than an 
icon tucked into the
+       corner of the name's button. */
+    .pill-eye {
+      padding: 5px 10px;
+      font-size: 13px;
+      border-left: 1px solid $border;
+      opacity: 0.65;
+
+      &:hover {
+        color: $blue;
+        background: rgba(24, 144, 255, 0.08);
+        opacity: 1;
+      }
+    }

Review Comment:
   Fixed, and your numbers check out: I recomputed them and got 2.06:1 for the 
hidden eye, which is what you measured. The dimming is gone -- the icon is 
drawn in ink instead (`rgba(0,0,0,.6)`), and the shown state uses a darker blue 
(`#096dd9`) because `#1890ff` on the chip's tinted ground is only 2.90:1. 
Measured against the surface behind each: 5.74:1 hidden, 4.48:1 shown, 4.58:1 
on hover. (7cb53d068)



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -1331,7 +1331,44 @@ export class WorkflowFormComponent implements OnInit, 
OnDestroy {
    * permanent "No result yet.".
    */
   public get resultIdsToShow(): string[] {
-    return this.shownResultIds.filter(id => 
this.workflowResultService.hasNonEmptyResult(id));
+    const ids = this.shownResultIds.filter(id => 
this.workflowResultService.hasNonEmptyResult(id));
+    // The selected step's card leads; the rest keep the saved order. Moving 
the card rather than
+    // scrolling to it keeps the preview the reader is clicking on in view. 
Read from the selection
+    // rather than kept beside it: two of them drifted apart (hiding the 
selected step's result
+    // cleared the lead but not the selection, and its name then read as 
"already leading" and let
+    // the step go instead of bringing the card back).
+    const lead = this.selectedOperatorId;
+    return lead !== undefined && ids.includes(lead) ? [lead, ...ids.filter(id 
=> id !== lead)] : ids;

Review Comment:
   Fixed. The cards keep their order in the document now and the lead is put 
first with `order` in a flex column, so no card's DOM is moved and no chart 
iframe is reloaded. `resultIdsToShow` is a plain filter again and the ordering 
lives in one `resultOrder` binding. The reading order is the saved one either 
way, and which result is being looked at is named there by the chip's 
`aria-current` rather than by position. The rendered test asserts the document 
order stays put while `style.order` moves. (7cb53d068)



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -1331,7 +1331,44 @@ export class WorkflowFormComponent implements OnInit, 
OnDestroy {
    * permanent "No result yet.".
    */
   public get resultIdsToShow(): string[] {
-    return this.shownResultIds.filter(id => 
this.workflowResultService.hasNonEmptyResult(id));
+    const ids = this.shownResultIds.filter(id => 
this.workflowResultService.hasNonEmptyResult(id));
+    // The selected step's card leads; the rest keep the saved order. Moving 
the card rather than
+    // scrolling to it keeps the preview the reader is clicking on in view. 
Read from the selection
+    // rather than kept beside it: two of them drifted apart (hiding the 
selected step's result
+    // cleared the lead but not the selection, and its name then read as 
"already leading" and let
+    // the step go instead of bringing the card back).
+    const lead = this.selectedOperatorId;
+    return lead !== undefined && ids.includes(lead) ? [lead, ...ids.filter(id 
=> id !== lead)] : ids;
+  }
+
+  /** Whether this step's card is at the front because it is the selected one 
-- what the ring marks,
+   *  on the card and on the step's chip. False for the usual first card. */
+  public leadsResults(operatorID: string): boolean {
+    return this.selectedOperatorId === operatorID && this.resultIdsToShow[0] 
=== operatorID;
+  }
+
+  /**
+   * A result's name, in either mode: a click selects that step, the same 
selection clicking the step
+   * on the preview makes -- through the action service, so co-editors see the 
ring as they do for a
+   * canvas click -- and its card comes to the front, ringed. Two steps with 
the same name are told
+   * apart by which one lights up. Clicking the name of the step already 
selected lets it go, putting
+   * the cards back. Nothing is written either way.
+   *
+   * A hidden result has no card to bring to the top, so its name does nothing 
at all: the template
+   * marks it unavailable, and this ignores it in case it is reached another 
way.
+   *
+   * The preview is left as the reader had it: opening it from here moved the 
results a third of the
+   * page down, out from under the name just clicked (#9033).
+   */
+  public onChoiceClick(choice: ResultChoice): void {
+    if (!choice.shown) {
+      return;
+    }
+    if (this.selectedOperatorId === choice.operatorID) {
+      this.closeOperatorPanel();
+      return;
+    }
+    this.workflowActionService.highlightOperators(false, choice.operatorID);

Review Comment:
   Confirmed and fixed. `highlightElement` returns at 
joint-graph-wrapper.ts:787 for an id it already holds, before the 
`!multiSelect` branch that would clear the others, so the click did nothing at 
all. `onChoiceClick` now lets the current selection go through the action 
service before highlighting, the harness models that early return (it ignores a 
request whose ids are all already highlighted), and there is a regression test: 
shift-select a and b, click b's name, b is the selection and its card leads. 
(7cb53d068)



-- 
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]

Reply via email to