bright-components 10.2.3 → 10.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ {
2
+ "eslint.format.enable": true,
3
+ "editor.renderWhitespace": "all",
4
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
5
+ "editor.formatOnSave": true,
6
+ "editor.formatOnPaste": true,
7
+ "cSpell.words": [
8
+ "autobind",
9
+ "brighthr",
10
+ "cronersupplieddocuments",
11
+ "firstname",
12
+ "Formik",
13
+ "lastname",
14
+ "pathnames",
15
+ "pendo",
16
+ "previewable",
17
+ "selectall",
18
+ "tailwindcss",
19
+ "testid",
20
+ "testprops"
21
+ ]
22
+ }
@@ -108,7 +108,7 @@ const ResponsiveTabs = _ref => {
108
108
  } = _ref,
109
109
  rest = _objectWithoutProperties(_ref, ["tabs", "defaultIndex", "children", "autoTabWidth", "onSelected"]);
110
110
 
111
- const [index, setIndex] = (0, _react.useState)(defaultIndex || 0);
111
+ const [index, setIndex] = (0, _react.useState)(defaultIndex < children.length ? defaultIndex : 0);
112
112
 
113
113
  const onSelectChange = (event, tabs) => {
114
114
  const names = tabs.map(tab => tab.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bright-components",
3
- "version": "10.2.3",
3
+ "version": "10.2.4",
4
4
  "private": false,
5
5
  "main": "./dist",
6
6
  "repository": {
@@ -94,7 +94,9 @@ const ResponsiveTabs = ({
94
94
  onSelected,
95
95
  ...rest
96
96
  }) => {
97
- const [index, setIndex] = useState(defaultIndex || 0);
97
+ const [index, setIndex] = useState(
98
+ defaultIndex < children.length ? defaultIndex : 0
99
+ );
98
100
 
99
101
  const onSelectChange = (event, tabs) => {
100
102
  const names = tabs.map(tab => tab.name);
@@ -7,6 +7,20 @@ import ResponsiveTabs from '.';
7
7
  jest.mock('react-ga');
8
8
 
9
9
  describe('<ResponsiveTabs />', () => {
10
+ it('should handle when defaultIndex is larger than the amount of tabs', () => {
11
+ const { getByRole, getAllByRole } = render(
12
+ <ResponsiveTabs defaultIndex={3}>
13
+ <TabPanel name="One">One</TabPanel>
14
+ <TabPanel name="Two">Two</TabPanel>
15
+ </ResponsiveTabs>
16
+ );
17
+
18
+ expect(getByRole('combobox')).toBeInTheDocument();
19
+ expect(getAllByRole('option')).toHaveLength(2);
20
+
21
+ // doesn't throw an error is good
22
+ });
23
+
10
24
  it('should render a dropdown for selecting tabs on mobile', () => {
11
25
  const { getByRole, getAllByRole } = render(
12
26
  <ResponsiveTabs>