Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): fixes illegal KMW event state - can't focus a null element #11385

Merged
merged 2 commits into from
May 10, 2024

Conversation

jahorton
Copy link
Contributor

@jahorton jahorton commented May 7, 2024

Fixes #11383.

@keymanapp-test-bot skip

@keymanapp-test-bot keymanapp-test-bot bot added this to the A18S1 milestone May 7, 2024
@jahorton jahorton force-pushed the fix/web/unexpected-null-element branch from 40f3a9a to 4fe7192 Compare May 7, 2024 02:12
@jahorton jahorton changed the base branch from master to beta May 7, 2024 02:12
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually I think I understand this change but there are a couple of rough edges

activeControl: previousTarget?.getElement()
});
const blurredElement = previousTarget?.getElement();
const focusedElement = target?.getElement();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as Ltarg above.

Also, there seems to be some overlapping logic in this function -- subtly different in what it tests, e.g. lines 278-282:

    if(this.focusAssistant.restoringFocus) {
      this._BlurKeyboardSettings(target.getElement());
    } else if(target) {
      this._FocusKeyboardSettings(target.getElement(), !hadRecentElement);
    }

So I am not clear on the reasons for the differences and what they add up to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did miss that it's a match for Ltarg.


As for the block you quoted, 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.

So, the quoted block here is about handling of keyboard settings, which is independent from detecting and updating which control is focused. They are a bit related though - if restoring focus, we're explicitly re-focusing an element that should already be considered active. If we're not, we could be changing focus in a number of different ways.

Comment on lines 316 to 318
// Note: indicates the previous control being blurred (as
// `activeControl`), so 'controlfocused' and 'controlblurred' are
// mutually exclusive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this comment -- the "so" second part doesn't seem to follow from the first part.

@mcdurdin
Copy link
Member

mcdurdin commented May 8, 2024

I notice the web build failed. Haven't investigated why...

@jahorton jahorton merged commit dd3763b into beta May 10, 2024
15 checks passed
@jahorton jahorton deleted the fix/web/unexpected-null-element branch May 10, 2024 00:32
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.322-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

bug(web): TypeError: Cannot read properties of null (reading 'tagName')
3 participants