Skip to content

Commit

Permalink
Change: powerFilter width and select loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-mng authored and bjoernricks committed Jun 14, 2024
1 parent e9372a2 commit 9970de6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 11 additions & 15 deletions src/web/components/form/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, {useCallback} from 'react';
import {useCallback, useState, useEffect} from 'react';

import {TextInput, Loader} from '@mantine/core';

Expand All @@ -35,7 +35,7 @@ const SelectValueValidator = (props, propName, componentName) => {
const value = props[propName];
const {items} = props;

if (!items || !items.length) {
if (!items?.length) {
return;
}

Expand Down Expand Up @@ -99,31 +99,27 @@ const Select = ({
[name, onChange],
);

if (isLoading) {
return (
<TextInput
styles={{root: {flexGrow: grow}}}
placeholder={_('Loading...')}
readOnly={true}
rightSection={<Loader size="xs" />}
/>
);
}
const selectPlaceholder = isLoading ? _('Loading...') : placeholder;
const rightSection = isLoading && <Loader size="xs" />;
const selectableItems = isLoading ? [] : items;
const selectedValue = isLoading ? undefined : value;

return (
<OpenSightSelect
{...props}
styles={{root: {flexGrow: grow}}}
dropdownPosition={dropdownPosition}
data={items}
data={selectableItems}
disabled={disabled || !items?.length}
error={isDefined(errorContent) && `${errorContent}`}
searchable={searchable}
label={label}
title={toolTipTitle}
placeholder={placeholder}
placeholder={selectPlaceholder}
name={name}
value={value}
value={selectedValue}
onChange={handleChange}
rightSection={rightSection}
/>
);
};
Expand Down
6 changes: 5 additions & 1 deletion src/web/components/powerfilter/powerfilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ const LeftDivider = styled(Divider)`
margin-right: 5px;
`;

const PowerFilterTextField = styled(TextField)`
width: 30vw;
`;

const getUserFilterString = filter => {
if (isDefined(filter) && isDefined(filter.toFilterCriteriaString)) {
return filter.toFilterCriteriaString();
Expand Down Expand Up @@ -195,7 +199,7 @@ class PowerFilter extends React.Component {
<Label>
<b>{_('Filter')}</b>
</Label>
<TextField
<PowerFilterTextField
name="userFilterString"
size="53"
maxLength="1000"
Expand Down

0 comments on commit 9970de6

Please sign in to comment.