twenty
twenty copied to clipboard
Be able to scope usePreviousHotkeyScope()
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, I feel this overkill from an api user perspective. couldn't we hide this stackId complexity behind the scene and keep the existing API?
@lucasbordeau quick bump on Charles' comment above. Should we keep this issue open?
We can close this ticket as it's not relevant anymore, the API is now stabilized.