Skip to content

Commit

Permalink
Update method for accessing list node ref in tag picker to make linte…
Browse files Browse the repository at this point in the history
…r happy
  • Loading branch information
rhystmills committed Dec 10, 2024
1 parent fd304e3 commit 65dddf3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions public/video-ui/src/components/CapiSearch/CapiSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
class CapiSearch extends React.Component {
constructor(props) {
super(props);
this.listNode = React.createRef();
}

componentDidUpdate(prevProps) {
Expand All @@ -12,9 +13,10 @@ class CapiSearch extends React.Component {
nextProps.selectedTagIndex !== null &&
prevProps.selectedTagIndex !== nextProps.selectedTagIndex
) {
const listNode = this.refs.list;
const elementHeight = listNode.children[0].offsetHeight;
if (listNode) {
const listNode = this.listNode.current;
if (listNode && listNode.children && listNode.children[0]) {
const elementHeight = listNode.children[0].offsetHeight;

listNode.scrollTop =
elementHeight *
(nextProps.selectedTagIndex === 0
Expand Down Expand Up @@ -62,7 +64,7 @@ class CapiSearch extends React.Component {
if (this.props.capiTags.length !== 0 && this.props.showTags) {
return (
<ul
ref="list"
ref={this.listNode}
className="form__field__tags"
onMouseDown={this.props.tagsToVisible}
>
Expand Down

0 comments on commit 65dddf3

Please sign in to comment.