• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 988636826

01 Sep 2023 04:04AM UTC coverage: 82.384% (-17.6%) from 99.964%
988636826

Pull #3969

gitlab-ci

web-flow
chore: Bump autoprefixer from 10.4.14 to 10.4.15

Bumps [autoprefixer](https://github.com/postcss/autoprefixer) from 10.4.14 to 10.4.15.
- [Release notes](https://github.com/postcss/autoprefixer/releases)
- [Changelog](https://github.com/postcss/autoprefixer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/autoprefixer/compare/10.4.14...10.4.15)

---
updated-dependencies:
- dependency-name: autoprefixer
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3969: chore: Bump autoprefixer from 10.4.14 to 10.4.15

4346 of 6321 branches covered (0.0%)

8259 of 10025 relevant lines covered (82.38%)

192.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.21
/src/js/components/common/chipselect.js
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React, { useEffect, useState } from 'react';
15

16
import { Autocomplete, TextField } from '@mui/material';
17

18
import { TIMEOUTS } from '../../constants/appConstants';
19
import { duplicateFilter, unionizeStrings } from '../../helpers';
20
import { useDebounce } from '../../utils/debouncehook';
21

22
export const ChipSelect = ({
9✔
23
  className = '',
79✔
24
  id = 'chip-select',
×
25
  selection = [],
×
26
  disabled = false,
79✔
27
  inputRef,
28
  label = '',
×
29
  onChange,
30
  options = [],
×
31
  placeholder = ''
×
32
}) => {
33
  const [value, setValue] = useState('');
79✔
34
  const [currentSelection, setCurrentSelection] = useState(selection);
79✔
35

36
  const debouncedValue = useDebounce(value, TIMEOUTS.debounceDefault);
79✔
37

38
  useEffect(() => {
79✔
39
    onChange({ currentValue: debouncedValue, selection: currentSelection });
35✔
40
    // eslint-disable-next-line react-hooks/exhaustive-deps
41
  }, [debouncedValue, JSON.stringify(currentSelection), onChange]);
42

43
  // to allow device types to automatically be selected on entered ',' we have to filter the input and transform any completed device types (followed by a ',')
44
  // while also checking for duplicates and allowing complete resets of the input
45
  const onTextInputChange = (inputValue, reason) => {
79✔
46
    const value = inputValue || '';
18✔
47
    if (reason === 'clear') {
18!
48
      setValue('');
×
49
      return setCurrentSelection([]);
×
50
    } else if (reason === 'reset') {
18!
51
      return setValue('');
×
52
    }
53
    const lastIndex = value.lastIndexOf(',');
18✔
54
    const possibleSelection = value.substring(0, lastIndex).split(',').filter(duplicateFilter);
18✔
55
    const currentValue = value.substring(lastIndex + 1);
18✔
56
    const nextSelection = unionizeStrings(currentSelection, possibleSelection);
18✔
57
    setValue(currentValue);
18✔
58
    setCurrentSelection(nextSelection);
18✔
59
  };
60

61
  const onTextInputLeave = value => {
79✔
62
    const nextSelection = unionizeStrings(currentSelection, [value]);
1✔
63
    setValue('');
1✔
64
    setCurrentSelection(nextSelection);
1✔
65
  };
66

67
  return (
79✔
68
    <Autocomplete
69
      id={id}
70
      value={currentSelection}
71
      className={className}
72
      filterSelectedOptions
73
      freeSolo={true}
74
      includeInputInList={true}
75
      multiple
76
      // allow edits to the textinput without deleting existing device types by ignoring backspace
77
      onChange={(e, value) => (e.key !== 'Backspace' ? setCurrentSelection(value) : null)}
×
78
      onInputChange={(e, v, reason) => onTextInputChange(null, reason)}
9✔
79
      options={options}
80
      readOnly={disabled}
81
      renderInput={params => (
82
        <TextField
82✔
83
          {...params}
84
          fullWidth
85
          inputProps={{ ...params.inputProps, value }}
86
          InputProps={{ ...params.InputProps, disableUnderline: disabled }}
87
          key={`${id}-input`}
88
          label={label}
89
          onBlur={e => onTextInputLeave(e.target.value)}
1✔
90
          onChange={e => onTextInputChange(e.target.value, 'input')}
9✔
91
          placeholder={currentSelection.length ? '' : placeholder}
82✔
92
          inputRef={inputRef}
93
        />
94
      )}
95
    />
96
  );
97
};
98

99
export default ChipSelect;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc