twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Be able to scope usePreviousHotkeyScope()

Open lucasbordeau opened this issue 2 years ago • 2 comments
trafficstars

Context : usePreviousHotkeyScope can be used to set the global hotkey scope of the application while retaining its previous value for going back to it later.

Problem : If two setHotkeyScopeAndMemorizePreviousScope are called, they will overwrite the same recoil state (previousHotkeyScopeState)

Proposed solution : We can add a parameter hotkeyScopeStackId: string to usePreviousHotkeyScope and turn the previousHotkeyScopeState into a familyState, so multiple components can memorize their previous hotkey scope.

Right now we're using it like this :

const {
  setHotkeyScopeAndMemorizePreviousScope,
  goBackToPreviousHotkeyScope,
} = usePreviousHotkeyScope();

function handleClosePicker() {
  goBackToPreviousHotkeyScope();
}

function handleOpenPicker() {
  setHotkeyScopeAndMemorizePreviousScope(
    RelationPickerHotkeyScope.RelationPicker,
  );
}

We could have this :

const {
  setHotkeyScopeAndMemorizePreviousScope,
  goBackToPreviousHotkeyScope,
} = usePreviousHotkeyScope(HotkeyScopeStackId.AddPersonToCompany); 

function handleClosePicker() {
  goBackToPreviousHotkeyScope();
}

function handleOpenPicker() {
  setHotkeyScopeAndMemorizePreviousScope(
    RelationPickerHotkeyScope.RelationPicker,
  );
}

lucasbordeau avatar Sep 04 '23 09:09 lucasbordeau

@lucasbordeau, I feel this overkill from an api user perspective. couldn't we hide this stackId complexity behind the scene and keep the existing API?

charlesBochet avatar Sep 05 '23 10:09 charlesBochet

@lucasbordeau quick bump on Charles' comment above. Should we keep this issue open?

FelixMalfait avatar Dec 31 '23 12:12 FelixMalfait

We can close this ticket as it's not relevant anymore, the API is now stabilized.

lucasbordeau avatar Jan 08 '24 10:01 lucasbordeau