Skip to content

Commit

Permalink
feat: expand item if searchableText is setted
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed May 30, 2024
1 parent 518dd35 commit f944032
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const CartellaModulisticaView = ({ content }) => {
<TextOrBlocks content={content} />

{/* -------SEARCH------- */}
{content?.ricerca_in_testata && (
{(true || content?.ricerca_in_testata) && (
<CartellaModulisticaSearchBar setSearchableText={setSearchableText} />
)}

Expand Down
13 changes: 11 additions & 2 deletions src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 = (
<div
Expand Down

0 comments on commit f944032

Please sign in to comment.