Skip to content

Commit

Permalink
[frontend] Allow sorting even when entering searche (#9280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwendoline-FAVRE-FELIX committed Jan 14, 2025
1 parent bb71acd commit c22c764
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, useState } from 'react';
import React, {useEffect, useRef, useState} from 'react';
import { Field, Form, Formik } from 'formik';
import { v4 as uuid } from 'uuid';
import { graphql } from 'react-relay';
Expand Down Expand Up @@ -503,18 +503,19 @@ const StixNestedRefRelationshipCreationFromEntity = ({
}
};

useEffect(() => {
setSortBy('created_at');
setOrderAsc(false);
}, [searchTerm]);

const renderSelectEntity = () => {
const searchPaginationOptions = {
search: searchTerm,
filters: removeIdFromFilterGroupObject(filters),
orderBy: null,
orderMode: null,
orderBy: sortBy,
orderMode: orderAsc ? 'asc' : 'desc',
types: targetStixCoreObjectTypes,
};
if (searchTerm.length === 0) {
searchPaginationOptions.orderBy = sortBy;
searchPaginationOptions.orderMode = orderAsc ? 'asc' : 'desc';
}
const dataColumns = {
entity_type: {
label: 'Type',
Expand Down

0 comments on commit c22c764

Please sign in to comment.