Skip to content

Commit

Permalink
Merge pull request #1311 from jcardus/master
Browse files Browse the repository at this point in the history
Sort device categories and attributes
  • Loading branch information
tananaev authored Feb 27, 2025
2 parents f999aaf + 4da6c59 commit 4fb086b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/settings/DevicePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const DevicePage = () => {
data={deviceCategories.map((category) => ({
id: category,
name: t(`category${category.replace(/^\w/, (c) => c.toUpperCase())}`),
}))}
})).sort((a, b) => a.name.localeCompare(b.name))}
label={t('deviceCategory')}
/>
<SelectField
Expand Down
6 changes: 3 additions & 3 deletions src/settings/components/AddAttributeDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useMemo } from 'react';
import {
Button, Dialog, DialogActions, DialogContent, FormControl, InputLabel, MenuItem, Select, TextField, Autocomplete,
} from '@mui/material';
Expand All @@ -25,11 +25,11 @@ const AddAttributeDialog = ({ open, onResult, definitions }) => {
stringify: (option) => option.name,
});

const options = Object.entries(definitions).map(([key, value]) => ({
const options = useMemo(() => Object.entries(definitions).map(([key, value]) => ({
key,
name: value.name,
type: value.type,
}));
})).sort((a, b) => a.name.localeCompare(b.name)), [definitions]);

const [key, setKey] = useState();
const [type, setType] = useState('string');
Expand Down

0 comments on commit 4fb086b

Please sign in to comment.