Add guard for undefined value in getEmoji
What does this MR do?
This MR fixes a regression introduced in !42669 (merged) which causes the following console error in issue list page.
what causes the console error?
gl-emoji
is a web component for displaying an emoji. Here's an example usage:
`<gl-emoji data-name="star" ...>`.
Using the data-name attribute, gl-emoji
initializes its emoji info using getEmojiInfo
function from ~/emoji/index.js
:
// gl_emoji.js#L16: "name" comes from "data-name"
const emojiInfo = getEmojiInfo(name);
When data-name is not supplied (so input is undefined
), getEmojiInfo
used to return a fallback emoji prior to !42669 (merged). After !42669 (merged), getEmojiInfo
doesn't directly return a fallback value but rather let other functions(getEmoji
/searchEmoji
) deal with undefined
input and toLowerCase()
ends up getting called on undefined
.
This MR adds a check for undefined
in getEmoji
/searchEmoji
so that these can return null
. We should follow up to restore the fallback behavior that was in place before !42669 (merged) - (tracked in #268208 (closed))
gl-emoji
used without data-name attribute?
when and why is In the filtered search bar in issue list, we pre-load gl-emoji
components _search_bar.html.haml#L139 without data attributes in the background.
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team