chore(web): better names for internal keyboard-setting functions
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
> As for the block you quoted [...]
```typescript
if(this.focusAssistant.restoringFocus) {
this._BlurKeyboardSettings(target.getElement());
} else if(target) {
this._FocusKeyboardSettings(target.getElement(), !hadRecentElement);
}
```
> [...], that's about maintaining proper connection between the active element and any control-specific keyboard settings. If focus was lost - like when the user interacts with a UI module - and then regained while the "restoring focus" mode is on, that indicates that the user just directly adjusted the keyboard settings for the current control. `_BlurKeyboardSettings` saves those settings, while `_FocusKeyboardSettings` restores them.
>
> Admittedly, those details - what the two functions represent - are a case of "headspace documentation", I suppose - the two functions were originally refactored our from general control focus and control blur handling. The names made sense then, but probably do make less sense now in their present form.
_Originally posted by @jahorton in https://github.com/keymanapp/keyman/pull/11385#discussion_r1591883563_
Better names would likely be "saveKeyboardSettings" and "loadKeyboardSettings" or similar. Note that when the "global" keyboard is "saved" via the former, that _does_ save the keyboard as "most recent" in the KMW cookie, which is used to attempt reactivation of it on future page visits.
If used to save settings for an "independent-mode" control, it does save and store _that control's_ settings in the relevant internal tracking. So, I think this nomenclature would work.
Contributor guide
Research direction
Search the web TypeScript code for _BlurKeyboardSettings and _FocusKeyboardSettings, then read their callers and the surrounding focus-restoration logic. Rename the functions to reflect saving and loading keyboard settings, update every reference, and verify that global and independent-mode behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100