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

MOSIP-32957: Filter dropdown fixes #379

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pmp-reactjs-ui/src/pages/common/fields/DropdownComponent.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@

import { useState, useEffect } from 'react';
import { useState, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { handleMouseClickForDropdown } from '../../../utils/AppUtils';

function DropdownComponent({ fieldName, dropdownDataList, onDropDownChangeEvent, fieldNameKey, dropDownPlaceHolder }) {

const { t } = useTranslation();

const [selectedDropdownEntry, setSelectedDropdownEntry] = useState("");
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const dropdownRef = useRef(null);

useEffect(() => {
const clickOutSideDropdown = handleMouseClickForDropdown(dropdownRef, () => setIsDropdownOpen(false));
return clickOutSideDropdown;
}, [dropdownRef]);

const changeDropdownSelection = (selectedid) => {
setSelectedDropdownEntry(selectedid);
Expand All @@ -23,7 +30,7 @@ function DropdownComponent({ fieldName, dropdownDataList, onDropDownChangeEvent,
<label className="block text-indigo-900 text-sm font-semibold mb-2">
{t(fieldNameKey)}:
</label>
<div className="relative w-full">
<div className="relative w-full" ref={dropdownRef}>
<button onClick={openDropdown} className="flex items-center justify-between w-[282px] h-10 px-2 py-2 border border-gray-400 bg-white rounded-[4px] text-base text-[15px] text-gray-800 leading-tight focus:outline-none focus:shadow-none" type="button">
<span>{
selectedDropdownEntry ?
Expand All @@ -42,7 +49,7 @@ function DropdownComponent({ fieldName, dropdownDataList, onDropDownChangeEvent,
return (
<div key={index} className="min-h-3">
<button
className={`block w-full px-4 py-2 text-left text-base text-blue-950
className={`block w-full h-8 px-4 py-1 text-left text-base text-blue-950
${selectedDropdownEntry === dropdownItem.fieldCode ? 'bg-gray-100' : 'hover:bg-gray-100'}`}
onClick={() => changeDropdownSelection(dropdownItem.fieldValue)}>
{dropdownItem.fieldCode}
Expand Down
Loading