Open pcafstockf opened 5 years ago
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
Please describe the feature you would like to request.
Please extend the FocusMonitor to better align with document.activeElement, by treating window deactivation as a slightly different case than a loss of focus resulting from the user actually clicking on a different element of the page. Also a way to detect window re-activation as opposed to user selection of an element.
What is the use-case or motivation for this proposal?
When a browser window loses focus, document.activeElement is not changed. From the DOM's point of view, there is still an "active" element, but the FocusMonitor treats this the same as if the user had simply clicked somewhere else on the page. There are cases where we don't want to blur the state of the page just because it is no longer the active window, and cases where we don't want to go through a re-focus process just because the window became active again.
Is there anything else we should know?
This change could easily be implemented with minimal breakage by using undefined to mean window deactivated (as both undefined and null are falsey). 'window' could then be added as a FocusOrigin value to signal window activation.
The implementation below has been working well in my own project, but it seems useful enough to merge into the base FocusMonitor.
` export type FocusOriginEx = FocusOrigin | 'window' | undefined;
@Injectable() export class FocusMonitorEx extends FocusMonitor {
} `