(core) Improve focus and keyboard shortcuts in modals.

Summary:
- Factor out focusing logic from Clipboard to FocusLayer.
- Generalize FocusLayer to support adding a temporary layer while a modal is open.
- Stop Mousetrap shortcuts while a modal is open.
- Refactor how Mousetrap's custom stopCallback is implemented to avoid
  needing to bundle knockout for mousetrap.

Test Plan: Added a test that Enter in a UserManager doesn't open a cell editor from underneath the modal.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2626
This commit is contained in:
Dmitry S
2020-10-02 15:26:14 -04:00
parent 1654a2681f
commit 90db5020c9
6 changed files with 224 additions and 81 deletions

View File

@@ -49,6 +49,14 @@ export class RefCountMap<Key, Value> implements IDisposable {
};
}
/**
* Return the value for the key, if one is set, or undefined otherwise, without touching
* reference counts.
*/
public get(key: Key): Value|undefined {
return this._map.get(key)?.value;
}
/**
* Purge a key by immediately removing it from the map. Disposing the remaining IRefCountSub
* values will be no-ops.