Skip to content

Commit 362da7b

Browse files
committed
[IMP] formula assistant: avoid information overload in the header.
Avoid overload in the helper UI header when multiple arguments are repeated. Task: 5358748
1 parent a95d9a4 commit 362da7b

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

src/components/composer/formula_assistant/formula_assistant.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@ export class FunctionDescriptionProvider extends Component<Props, SpreadsheetChi
7272
if (displayBrackets) {
7373
result.push({ content: "]" });
7474
}
75-
result.push({ content: argSeparator + "[" });
76-
for (let idx = 0; idx < repeatingArgNames.length; idx++) {
77-
const name = repeatingArgNames[idx];
78-
result.push({ content: name + ((repeatingArgGroupIndex ?? 0) + 2) });
79-
// Add separator after each element except the last
80-
if (idx < repeatingArgNames.length - 1) {
81-
result.push({ content: argSeparator });
75+
if (functionDescription.nbrArgRepeating <= 1) {
76+
result.push({ content: argSeparator + "[" });
77+
for (let idx = 0; idx < repeatingArgNames.length; idx++) {
78+
const name = repeatingArgNames[idx];
79+
result.push({ content: name + ((repeatingArgGroupIndex ?? 0) + 2) });
80+
// Add separator after each element except the last
81+
if (idx < repeatingArgNames.length - 1) {
82+
result.push({ content: argSeparator });
83+
}
8284
}
85+
result.push({ content: "]" });
8386
}
84-
result.push({ content: "]" + argSeparator + "... " });
87+
result.push({ content: argSeparator + "... " });
8588

8689
// Skip the processed repeating args
8790
i += functionDescription.nbrArgRepeating - 1;

tests/composer/formula_assistant_component.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,35 @@ describe("formula assistant", () => {
319319
expect(fixture.querySelectorAll(".o-formula-assistant-head")[0].textContent).toBe(
320320
"FUNC3 ( f3ArgA, f3ArgB1, [f3ArgB2], ... )"
321321
);
322+
323+
await typeInComposer(", ,", false);
324+
expect(fixture.querySelectorAll(".o-formula-assistant-head")[0].textContent).toBe(
325+
"FUNC3 ( f3ArgA, ... , [f3ArgB2], [f3ArgB3], ... )"
326+
);
327+
});
328+
329+
test("function with repeatable argument optional", async () => {
330+
await typeInComposer("=FUNC3BIS(");
331+
expect(fixture.querySelectorAll(".o-formula-assistant-head")[0].textContent).toBe(
332+
"FUNC3BIS ( f3bisArgA, [f3bisArgB1], [f3bisArgB2], ... )"
333+
);
334+
335+
await typeInComposer(", ,", false);
336+
expect(fixture.querySelectorAll(".o-formula-assistant-head")[0].textContent).toBe(
337+
"FUNC3BIS ( f3bisArgA, ... , [f3bisArgB2], [f3bisArgB3], ... )"
338+
);
339+
});
340+
341+
test("function with multiple repeatable arguments", async () => {
342+
await typeInComposer("=UPTOWNFUNC(");
343+
expect(fixture.querySelectorAll(".o-formula-assistant-head")[0].textContent).toBe(
344+
"UPTOWNFUNC ( f4ArgA, f4ArgB1, f4ArgC1, ... )"
345+
);
346+
347+
await typeInComposer(", , ,", false);
348+
expect(fixture.querySelectorAll(".o-formula-assistant-head")[0].textContent).toBe(
349+
"UPTOWNFUNC ( f4ArgA, ... , [f4ArgB2, f4ArgC2], ... )"
350+
);
322351
});
323352

324353
test("arguments separator is localized", async () => {

0 commit comments

Comments
 (0)