Skip to content

fix: invalid enum check in HoverFocusBehavior logic#200237

Merged
aiday-mar merged 1 commit intomicrosoft:mainfrom
idootop:fix/enum-check
Dec 7, 2023
Merged

fix: invalid enum check in HoverFocusBehavior logic#200237
aiday-mar merged 1 commit intomicrosoft:mainfrom
idootop:fix/enum-check

Conversation

@idootop
Copy link
Copy Markdown
Contributor

@idootop idootop commented Dec 7, 2023

Problem

The existing implementation uses the in operator to check if a string is a valid enum member in HoverFocusBehavior. This check is ineffective because the in operator checks for the presence of keys in an object, not string values.

Related information: https://stackoverflow.com/a/43805090

图片

Solution

This PR fixes the issue by replacing the in operator with Object.values() combined with includes() to properly check if the provided focusArgument is a valid string value of the HoverFocusBehavior enum.

The change ensures that the focus behavior logic is correctly applied, preventing any unintended focus behavior due to incorrect enum value checks.

@idootop
Copy link
Copy Markdown
Contributor Author

idootop commented Dec 7, 2023

@aiday-mar cc

@aiday-mar
Copy link
Copy Markdown
Contributor

Ah yes thanks a lot for picking up on this issue. Indeed you are completely right. We'll merge this.

@lramos15 lramos15 assigned aiday-mar and unassigned lramos15 Dec 7, 2023
@aiday-mar aiday-mar merged commit 4fce419 into microsoft:main Dec 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants