Skip to content

Commit c22c764

Browse files
[frontend] Allow sorting even when entering searche (#9280)
1 parent bb71acd commit c22c764

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

opencti-platform/opencti-front/src/private/components/common/stix_nested_ref_relationships/StixNestedRefRelationshipCreationFromEntity.jsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useState } from 'react';
1+
import React, {useEffect, useRef, useState} from 'react';
22
import { Field, Form, Formik } from 'formik';
33
import { v4 as uuid } from 'uuid';
44
import { graphql } from 'react-relay';
@@ -503,18 +503,19 @@ const StixNestedRefRelationshipCreationFromEntity = ({
503503
}
504504
};
505505

506+
useEffect(() => {
507+
setSortBy('created_at');
508+
setOrderAsc(false);
509+
}, [searchTerm]);
510+
506511
const renderSelectEntity = () => {
507512
const searchPaginationOptions = {
508513
search: searchTerm,
509514
filters: removeIdFromFilterGroupObject(filters),
510-
orderBy: null,
511-
orderMode: null,
515+
orderBy: sortBy,
516+
orderMode: orderAsc ? 'asc' : 'desc',
512517
types: targetStixCoreObjectTypes,
513518
};
514-
if (searchTerm.length === 0) {
515-
searchPaginationOptions.orderBy = sortBy;
516-
searchPaginationOptions.orderMode = orderAsc ? 'asc' : 'desc';
517-
}
518519
const dataColumns = {
519520
entity_type: {
520521
label: 'Type',

0 commit comments

Comments
 (0)