diff --git a/client/src/shared/components/Select/Dropdown.jsx b/client/src/shared/components/Select/Dropdown.jsx
index 2d5ce9a..92d086d 100644
--- a/client/src/shared/components/Select/Dropdown.jsx
+++ b/client/src/shared/components/Select/Dropdown.jsx
@@ -1,4 +1,4 @@
-import React, { useState, useRef } from 'react';
+import React, { useState, useRef, useLayoutEffect } from 'react';
import PropTypes from 'prop-types';
import { uniq } from 'lodash';
@@ -47,6 +47,18 @@ const SelectDropdown = ({
const $optionsRef = useRef();
+ useLayoutEffect(() => {
+ const setFirstOptionAsActive = () => {
+ const $active = getActiveOptionNode();
+ if ($active) $active.classList.remove(activeOptionClass);
+
+ if ($optionsRef.current.firstElementChild) {
+ $optionsRef.current.firstElementChild.classList.add(activeOptionClass);
+ }
+ };
+ setFirstOptionAsActive();
+ });
+
const selectOptionValue = optionValue => {
deactivateDropdown();
if (isMulti) {
@@ -139,7 +151,7 @@ const SelectDropdown = ({
const handleOptionMouseEnter = event => {
const $active = getActiveOptionNode();
if ($active) $active.classList.remove(activeOptionClass);
- event.target.classList.add(activeOptionClass);
+ event.currentTarget.classList.add(activeOptionClass);
};
const getActiveOptionNode = () => $optionsRef.current.querySelector(`.${activeOptionClass}`);
@@ -161,10 +173,9 @@ const SelectDropdown = ({
const isSearchValueInOptions = options.map(option => option.label).includes(searchValue);
const isOptionCreatable = onCreate && searchValue && !isSearchValueInOptions;
- const renderSelectableOption = (option, i) => (
+ const renderSelectableOption = option => (