Skip to content

Conversation

@hokolomopo
Copy link
Contributor

@hokolomopo hokolomopo commented Dec 4, 2025

Description:

This commits adds the named ranges feature, that allows to defined a
custom name for a range of cells, and use that name in formulas.

Task: 5380498

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Dec 4, 2025

Pull request status dashboard

@hokolomopo hokolomopo force-pushed the master-named-range-adrm branch 2 times, most recently from d5688ce to 36b71ca Compare December 5, 2025 13:38
protected initialContent: string | undefined = "";
private colorIndexByRange: { [xc: string]: number } = {};
private autoComplete: Store<AutoCompleteStore> = new AutoCompleteStore(this.get);
private hasSelectedAProposal: boolean = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kinda sucks ... but I don't have a better idea.

The problem is if we open a composer on a formula like =MyNamedRange. The autocomplete dropdown is open, and MyNamedRange is selected. If we press enter, provider.selectProposal will be called, do nothing, the dropdown will be closed ... and the promptly re-opened since nothing changed, so pressing enter will do absolutely nothing and we cannot close the composer.

And we don't want to hide the dropdown if this._currentContent === this.initialContent otherwise we don't have functions auto-complete either ...

@hokolomopo hokolomopo force-pushed the master-named-range-adrm branch 4 times, most recently from 71acd88 to ec5e66f Compare December 12, 2025 12:05
@hokolomopo hokolomopo force-pushed the master-named-range-adrm branch 2 times, most recently from fa95e29 to 629d0a0 Compare December 16, 2025 08:37
@hokolomopo hokolomopo changed the title Master named range adrm [IMP] spreadsheet: add named ranges feature Dec 16, 2025
@hokolomopo hokolomopo force-pushed the master-named-range-adrm branch from 629d0a0 to 1c54b28 Compare December 16, 2025 08:40
With this commit, we now give the full proposal object as argument of
`selectProposal` method of auto-complete providers, instead of only the
text value of the proposal.

This will be useful for the named range autocomplete, as we need to
differentiate between a function and named range proposal.

Task: 5380498
The `props.onChange` of the `TextInput` was called three times when
pressing enter:
1) once in the `onKeyDown` when we called `this.save()`
2) once in the `save` when we called `this.inputRef.el?.blur()`, which
    triggered the `onBlur` event listener
3) once again in the `save` when we called `this.inputRef.el?.blur()`,
    because HTML input elements trigger the `onChange` event when
    losing focus.

This is very problematic when `props.onChange` dispatches a command
for example.

The issue was fixed by adding a `lastOnChangeValue` property that
stores the last value sent to `props.onChange`, and preventing another
call if the value did not change[1].

Another problem was the `save` had a `keepFocus` that was never used,
except accidentally when we gave the event in place of this argument.

[1] A better fix would have been to blur the input on `Enter`, and rely
on the `onChange` event triggered by the HTML input element when losing
focus. But this behavior, even if it's in the HTML spec, isn't
implemented in JSDOM. So all of our test would stop working.

Task: 5380498
This commits adds the named ranges feature, that allows to defined a
custom name for a range of cells, and use that name in formulas.

Task: 5380498
@hokolomopo hokolomopo force-pushed the master-named-range-adrm branch from 1c54b28 to a3edf96 Compare December 17, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants