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

[FIX] autocomplete: Stop the range selection after selecting a pivot … #4980

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion src/helpers/pivot/pivot_composer_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { tokenColors } from "../../components/composer/composer/composer";
import { ComposerStore } from "../../components/composer/composer/composer_store";
import { Token, getFunctionsFromTokens } from "../../formulas";
import { getFunctionsFromTokens, Token } from "../../formulas";
import { EnrichedToken } from "../../formulas/composer_tokenizer";
import { Granularity, PivotField } from "../../types";

Expand Down Expand Up @@ -41,6 +41,7 @@ export function insertTokenAfterArgSeparator(
// replace the whole token
start = tokenAtCursor.start;
}
this.composer.stopComposerRangeSelection();
this.composer.changeComposerCursorSelection(start, end);
this.composer.replaceComposerCursorSelection(value);
}
Expand All @@ -63,6 +64,7 @@ export function insertTokenAfterLeftParenthesis(
// replace the whole token
start = tokenAtCursor.start;
}
this.composer.stopComposerRangeSelection();
this.composer.changeComposerCursorSelection(start, end);
this.composer.replaceComposerCursorSelection(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe("spreadsheet pivot auto complete", () => {
);
for (const func of ["PIVOT", "PIVOT.HEADER", "PIVOT.VALUE"]) {
composer.startEdition(`=${func}(`);
expect(composer.isSelectingRange).toBeTruthy();

const autoComplete = composer.autocompleteProvider;
expect(autoComplete?.proposals).toEqual([
{
Expand All @@ -36,6 +38,8 @@ describe("spreadsheet pivot auto complete", () => {
]);
autoComplete?.selectProposal(autoComplete?.proposals[0].text);
expect(composer.currentContent).toBe(`=${func}(1`);
// range selection stops
expect(composer.isSelectingRange).toBeFalsy();
expect(composer.autocompleteProvider).toBeUndefined();
composer.cancelEdition();
}
Expand All @@ -62,7 +66,7 @@ describe("spreadsheet pivot auto complete", () => {
}
});

test("PIVOT.VALUE measuresgd", async () => {
test("PIVOT.VALUE measures", async () => {
const model = createModelWithPivot("A1:I5");
updatePivot(model, "1", {
columns: [],
Expand Down