From f944032b03b64baf060f71ee1781f3f0b0fb11df Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Thu, 30 May 2024 13:54:53 +0200 Subject: [PATCH] feat: expand item if searchableText is setted --- .../CartellaModulisticaView.jsx | 2 +- .../View/CartellaModulisticaView/DocRow.jsx | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx b/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx index 153ffa96b..4931bf765 100644 --- a/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx +++ b/src/components/ItaliaTheme/View/CartellaModulisticaView/CartellaModulisticaView.jsx @@ -108,7 +108,7 @@ const CartellaModulisticaView = ({ content }) => { {/* -------SEARCH------- */} - {content?.ricerca_in_testata && ( + {(true || content?.ricerca_in_testata) && ( )} diff --git a/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx b/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx index b50eec561..f85c1714f 100644 --- a/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +++ b/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx @@ -3,7 +3,7 @@ * @module components/theme/View/DocRow */ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import cx from 'classnames'; import Highlighter from 'react-highlight-words'; @@ -59,7 +59,16 @@ const Downloads = ({ item, titleDoc, filteredWords }) => { const DocRow = ({ doc, items, searchableText }) => { const filteredWords = searchableText.split(' '); - const [itemOpen, setItemOpen] = useState(false); + const [itemOpen, setItemOpen] = useState(searchableText?.length > 0 ?? false); + + useEffect(() => { + //se ho fatto una ricerca, espando l'elemento + if (searchableText?.length > 0) { + setItemOpen(true); + } else { + setItemOpen(false); + } + }, [searchableText]); const titleWrapper = (