Skip to content

Commit

Permalink
[frontend] reset searchTerm when highlighting changes in content mapp…
Browse files Browse the repository at this point in the history
…ing (#9520)
  • Loading branch information
JeremyCloarec authored Jan 21, 2025
1 parent 22b113b commit ce00c80
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,18 @@ const ContainerAddStixCoreObjects = (props) => {
const contextFilters = useBuildEntityTypeBasedFilterContext(targetStixCoreObjectTypes, filters);

const containerRef = useRef(null);
const keyword = mapping && (searchTerm ?? '').length === 0 ? selectedText : searchTerm;
const [mappingSearch, setMappingSearch] = useState(null);
const [currentSelectedText, setCurrentSelectedText] = useState(selectedText);
if (currentSelectedText !== selectedText) {
setMappingSearch(null);
setCurrentSelectedText(selectedText);
}
let keyword;
if (!mapping) {
keyword = searchTerm;
} else {
keyword = !mappingSearch ? selectedText : mappingSearch;
}
const handleOpenCreateEntity = () => {
setOpenCreateEntity(true);
setOpenSpeedDial(false);
Expand Down Expand Up @@ -319,7 +330,7 @@ const ContainerAddStixCoreObjects = (props) => {
sortBy={sortBy}
orderAsc={orderAsc}
dataColumns={buildColumns()}
handleSearch={helpers.handleSearch}
handleSearch={mapping ? setMappingSearch : helpers.handleSearch}
keyword={keyword}
handleSort={helpers.handleSort}
handleAddFilter={helpers.handleAddFilter}
Expand Down

0 comments on commit ce00c80

Please sign in to comment.