From 5dc5d23fa1395f8e0e2579517a054e091329374b Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 5 May 2020 16:44:23 -0700 Subject: [PATCH 01/13] PR to merge packges for controls migration --- .../src/InfoTooltipWithTrigger.jsx | 71 +++++++++++++++++++ .../superset-ui-control-utils/src/index.ts | 1 + 2 files changed, 72 insertions(+) create mode 100644 packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx new file mode 100644 index 0000000000..4025f1f6fb --- /dev/null +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import PropTypes from 'prop-types'; +import { kebabCase } from 'lodash'; +import { Tooltip, OverlayTrigger } from 'react-bootstrap'; + +const propTypes = { + label: PropTypes.string.isRequired, + tooltip: PropTypes.string, + icon: PropTypes.string, + className: PropTypes.string, + onClick: PropTypes.func, + placement: PropTypes.string, + bsStyle: PropTypes.string, +}; +const defaultProps = { + icon: 'info-circle', + className: 'text-muted', + placement: 'right', +}; +const tooltipStyle = { wordWrap: 'break-word' }; + +export default function InfoTooltipWithTrigger({ + label, + tooltip, + icon, + className, + onClick, + placement, + bsStyle, +}) { + const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; + const iconEl = ( + + ); + if (!tooltip) { + return iconEl; + } + return ( + + {tooltip} + + } + > + {iconEl} + + ); +} + +InfoTooltipWithTrigger.propTypes = propTypes; +InfoTooltipWithTrigger.defaultProps = defaultProps; diff --git a/packages/superset-ui-control-utils/src/index.ts b/packages/superset-ui-control-utils/src/index.ts index 6e485f3577..ad48f4417e 100644 --- a/packages/superset-ui-control-utils/src/index.ts +++ b/packages/superset-ui-control-utils/src/index.ts @@ -3,3 +3,4 @@ import * as sectionModules from './sections'; export const sections = sectionModules; export { D3_FORMAT_DOCS, D3_FORMAT_OPTIONS, D3_TIME_FORMAT_OPTIONS } from './D3Formatting'; export { formatSelectOptions, formatSelectOptionsForRange } from './selectOptions'; +export { default as InfoTooltipWithTrigger } from './InfoTooltipWithTrigger'; From 5efe0293d9ae294853f0bcb75f730870b3b929ac Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 5 May 2020 17:13:12 -0700 Subject: [PATCH 02/13] fix: add bootstrap --- .../superset-ui-control-utils/package.json | 3 + .../src/InfoTooltipWithTrigger.jsx | 71 ------------------- 2 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx diff --git a/packages/superset-ui-control-utils/package.json b/packages/superset-ui-control-utils/package.json index 2d2f9a452b..4dc8bbed03 100644 --- a/packages/superset-ui-control-utils/package.json +++ b/packages/superset-ui-control-utils/package.json @@ -28,5 +28,8 @@ "peerDependencies": { "@superset-ui/translation": "^0.13", "@superset-ui/validator": "^0.13" + }, + "dependencies": { + "react-bootstrap": "^1.0.1" } } diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx deleted file mode 100644 index 4025f1f6fb..0000000000 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.jsx +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import React from 'react'; -import PropTypes from 'prop-types'; -import { kebabCase } from 'lodash'; -import { Tooltip, OverlayTrigger } from 'react-bootstrap'; - -const propTypes = { - label: PropTypes.string.isRequired, - tooltip: PropTypes.string, - icon: PropTypes.string, - className: PropTypes.string, - onClick: PropTypes.func, - placement: PropTypes.string, - bsStyle: PropTypes.string, -}; -const defaultProps = { - icon: 'info-circle', - className: 'text-muted', - placement: 'right', -}; -const tooltipStyle = { wordWrap: 'break-word' }; - -export default function InfoTooltipWithTrigger({ - label, - tooltip, - icon, - className, - onClick, - placement, - bsStyle, -}) { - const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; - const iconEl = ( - - ); - if (!tooltip) { - return iconEl; - } - return ( - - {tooltip} - - } - > - {iconEl} - - ); -} - -InfoTooltipWithTrigger.propTypes = propTypes; -InfoTooltipWithTrigger.defaultProps = defaultProps; From 9acf81330a98e948f47c96088b228dddce8a01a4 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 5 May 2020 17:20:49 -0700 Subject: [PATCH 03/13] fix: change tooltip to tsx --- .../src/InfoTooltipWithTrigger.tsx | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx new file mode 100644 index 0000000000..54dd479338 --- /dev/null +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import { kebabCase } from 'lodash'; +// @ts-ignore +import { Tooltip, OverlayTrigger } from 'react-bootstrap'; + +const defaultProps = { + icon: 'info-circle', + className: 'text-muted', + placement: 'right', +}; +const tooltipStyle = { wordWrap: 'break-word' } as any; + +export default function InfoTooltipWithTrigger({ + label, + tooltip, + icon, + className, + onClick, + placement, + bsStyle, +}) { + const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; + const iconEl = ( + + ); + if (!tooltip) { + return iconEl; + } + return ( + + {tooltip} + + } + > + {iconEl} + + ); +} + +InfoTooltipWithTrigger.defaultProps = defaultProps; From bf1296beee5ba73875110be66f0f53ffe67ea969 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 5 May 2020 17:54:23 -0700 Subject: [PATCH 04/13] fix: types --- .../src/InfoTooltipWithTrigger.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx index 54dd479338..bd398a5e4e 100644 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -28,6 +28,15 @@ const defaultProps = { }; const tooltipStyle = { wordWrap: 'break-word' } as any; +interface Props { + label: string; + tooltip: string; + icon: string; + onClick: Function; + placement: string; + bsStyle: string; +} + export default function InfoTooltipWithTrigger({ label, tooltip, @@ -39,7 +48,11 @@ export default function InfoTooltipWithTrigger({ }) { const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; const iconEl = ( - + ); if (!tooltip) { return iconEl; From 00561e3e7d516dd5b52ac8cdf0694170ac3dfb93 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 5 May 2020 18:12:25 -0700 Subject: [PATCH 05/13] fix: tsx error --- .../src/InfoTooltipWithTrigger.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx index bd398a5e4e..311a42a2da 100644 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -32,9 +32,10 @@ interface Props { label: string; tooltip: string; icon: string; - onClick: Function; + onClick: React.MouseEventHandler; placement: string; bsStyle: string; + className: string; } export default function InfoTooltipWithTrigger({ @@ -45,7 +46,7 @@ export default function InfoTooltipWithTrigger({ onClick, placement, bsStyle, -}) { +}: Props) { const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; const iconEl = ( {tooltip} From ed63e913c0933de901889fbc5bf7f7d8d629a3e1 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Tue, 5 May 2020 18:42:50 -0700 Subject: [PATCH 06/13] appease linter, enhance a11y --- packages/superset-ui-control-utils/package.json | 2 ++ .../src/InfoTooltipWithTrigger.tsx | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/superset-ui-control-utils/package.json b/packages/superset-ui-control-utils/package.json index 4dc8bbed03..949b2f1075 100644 --- a/packages/superset-ui-control-utils/package.json +++ b/packages/superset-ui-control-utils/package.json @@ -30,6 +30,8 @@ "@superset-ui/validator": "^0.13" }, "dependencies": { + "lodash": "^4.17.15", + "react": "^16.13.1", "react-bootstrap": "^1.0.1" } } diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx index 311a42a2da..467a8f586e 100644 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -22,8 +22,8 @@ import { kebabCase } from 'lodash'; import { Tooltip, OverlayTrigger } from 'react-bootstrap'; const defaultProps = { - icon: 'info-circle', className: 'text-muted', + icon: 'info-circle', placement: 'right', }; const tooltipStyle = { wordWrap: 'break-word' } as any; @@ -32,7 +32,7 @@ interface Props { label: string; tooltip: string; icon: string; - onClick: React.MouseEventHandler; + onClick: () => void; placement: string; bsStyle: string; className: string; @@ -48,11 +48,19 @@ export default function InfoTooltipWithTrigger({ bsStyle, }: Props) { const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; + const onKeyPress = (event: React.KeyboardEvent) => { + if (event.key === 'Enter' || event.key === 'space') { + onClick(); + } + }; const iconEl = ( ); if (!tooltip) { From 3fa07d25f5d5291708a0d48c6d09a8d50e9feb90 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Wed, 6 May 2020 15:42:39 -0700 Subject: [PATCH 07/13] addressing PR feedback --- .../superset-ui-control-utils/package.json | 10 ++++-- .../src/InfoTooltipWithTrigger.tsx | 36 ++++++++----------- .../test/InfoTooltipWithTrigger.test.tsx | 16 +++++++++ 3 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx diff --git a/packages/superset-ui-control-utils/package.json b/packages/superset-ui-control-utils/package.json index 949b2f1075..12fe1e6ffd 100644 --- a/packages/superset-ui-control-utils/package.json +++ b/packages/superset-ui-control-utils/package.json @@ -27,11 +27,15 @@ }, "peerDependencies": { "@superset-ui/translation": "^0.13", - "@superset-ui/validator": "^0.13" + "@superset-ui/validator": "^0.13", + "react": "^16.13.1" + }, + "devDependencies": { + "@types/react-bootstrap": "0.32.2", + "enzyme": "^3.11.0" }, "dependencies": { "lodash": "^4.17.15", - "react": "^16.13.1", - "react-bootstrap": "^1.0.1" + "react-bootstrap": "^0.33.1" } } diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx index 467a8f586e..b6bfee5603 100644 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -18,34 +18,28 @@ */ import React from 'react'; import { kebabCase } from 'lodash'; -// @ts-ignore import { Tooltip, OverlayTrigger } from 'react-bootstrap'; -const defaultProps = { - className: 'text-muted', - icon: 'info-circle', - placement: 'right', -}; -const tooltipStyle = { wordWrap: 'break-word' } as any; +const tooltipStyle: React.CSSProperties = { wordWrap: 'break-word' }; interface Props { - label: string; - tooltip: string; - icon: string; - onClick: () => void; - placement: string; - bsStyle: string; - className: string; + label?: string; + tooltip?: string; + icon?: string; + onClick?: () => void; + placement?: string; + bsStyle?: string; + className?: string; } export default function InfoTooltipWithTrigger({ label, tooltip, - icon, - className, - onClick, - placement, bsStyle, + icon = 'info-circle', + className = 'text-muted', + onClick = () => {}, + placement = 'right', }: Props) { const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; const onKeyPress = (event: React.KeyboardEvent) => { @@ -60,7 +54,7 @@ export default function InfoTooltipWithTrigger({ className={iconClass} style={{ cursor: onClick ? 'pointer' : undefined }} onClick={onClick} - onKeyPress={onClick && onKeyPress} + onKeyPress={onKeyPress} /> ); if (!tooltip) { @@ -68,7 +62,7 @@ export default function InfoTooltipWithTrigger({ } return ( {tooltip} @@ -79,5 +73,3 @@ export default function InfoTooltipWithTrigger({ ); } - -InfoTooltipWithTrigger.defaultProps = defaultProps; diff --git a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx new file mode 100644 index 0000000000..c6ec7372a6 --- /dev/null +++ b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import { Tooltip } from 'react-bootstrap'; +import InfoTooltipWithTrigger from '../src/InfoTooltipWithTrigger'; + +describe('InfoTooltipWithTrigger', () => { + it('renders a tooltip', () => { + const wrapper = shallow(); + expect(wrapper.find(Tooltip)).toHaveLength(1); + }); + + it('renders an info icon', () => { + const wrapper = shallow(); + expect(wrapper.find('.fa-info-circle')).toHaveLength(1); + }); +}); From dc8cb7ea4579580c799d4ced72fe96c94a8c498f Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Wed, 6 May 2020 17:17:39 -0700 Subject: [PATCH 08/13] tweaking bootstrap types --- packages/superset-ui-control-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/superset-ui-control-utils/package.json b/packages/superset-ui-control-utils/package.json index 12fe1e6ffd..5feafb0f38 100644 --- a/packages/superset-ui-control-utils/package.json +++ b/packages/superset-ui-control-utils/package.json @@ -31,10 +31,10 @@ "react": "^16.13.1" }, "devDependencies": { - "@types/react-bootstrap": "0.32.2", "enzyme": "^3.11.0" }, "dependencies": { + "@types/react-bootstrap": "0.32.21", "lodash": "^4.17.15", "react-bootstrap": "^0.33.1" } From 7f27efee24c580b67c7955410f4f7a212124e7ac Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Wed, 6 May 2020 23:06:03 -0700 Subject: [PATCH 09/13] fix test --- .../test/InfoTooltipWithTrigger.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx index c6ec7372a6..0a022198d1 100644 --- a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx +++ b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx @@ -1,12 +1,12 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { Tooltip } from 'react-bootstrap'; +import { OverlayTrigger } from 'react-bootstrap'; import InfoTooltipWithTrigger from '../src/InfoTooltipWithTrigger'; describe('InfoTooltipWithTrigger', () => { it('renders a tooltip', () => { const wrapper = shallow(); - expect(wrapper.find(Tooltip)).toHaveLength(1); + expect(wrapper.find(OverlayTrigger)).toHaveLength(1); }); it('renders an info icon', () => { From 694c63d4ff2e8f970748d556f37910ccf5bdc403 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Wed, 6 May 2020 23:44:31 -0700 Subject: [PATCH 10/13] test enter key --- .../test/InfoTooltipWithTrigger.test.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx index 0a022198d1..4a921a2918 100644 --- a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx +++ b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx @@ -13,4 +13,13 @@ describe('InfoTooltipWithTrigger', () => { const wrapper = shallow(); expect(wrapper.find('.fa-info-circle')).toHaveLength(1); }); + + it('responds to an enter key', () => { + const clickHandler = jest.fn(); + const wrapper = shallow( + , + ); + wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Enter' }); + expect(clickHandler).toHaveBeenCalled(); + }); }); From 8cac2d1790dc622164b9c5835e299776296c1328 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Thu, 7 May 2020 09:33:24 -0700 Subject: [PATCH 11/13] moar tests --- .../src/InfoTooltipWithTrigger.tsx | 16 +++++++++------- .../test/InfoTooltipWithTrigger.test.tsx | 13 +++++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx index b6bfee5603..475396971f 100644 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -36,17 +36,12 @@ export default function InfoTooltipWithTrigger({ label, tooltip, bsStyle, + onClick, icon = 'info-circle', className = 'text-muted', - onClick = () => {}, placement = 'right', }: Props) { const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`; - const onKeyPress = (event: React.KeyboardEvent) => { - if (event.key === 'Enter' || event.key === 'space') { - onClick(); - } - }; const iconEl = ( { + if (event.key === 'Enter' || event.key === 'space') { + onClick(); + } + }) + } /> ); if (!tooltip) { diff --git a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx index 4a921a2918..93888a6dac 100644 --- a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx +++ b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx @@ -14,12 +14,21 @@ describe('InfoTooltipWithTrigger', () => { expect(wrapper.find('.fa-info-circle')).toHaveLength(1); }); - it('responds to an enter key', () => { + it('responds to keypresses', () => { const clickHandler = jest.fn(); const wrapper = shallow( , ); + wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Tab' }); + expect(clickHandler).toHaveBeenCalledTimes(0); wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Enter' }); - expect(clickHandler).toHaveBeenCalled(); + expect(clickHandler).toHaveBeenCalledTimes(1); + wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Space' }); + expect(clickHandler).toHaveBeenCalledTimes(2); + }); + + it('has a bsStyle', () => { + const wrapper = shallow(); + expect(wrapper.find('.text-something')).toHaveLength(1); }); }); From c0ce659b450dd694e8b26ceeeb6b3e90474eda64 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Thu, 7 May 2020 10:06:11 -0700 Subject: [PATCH 12/13] code > key --- .../src/InfoTooltipWithTrigger.tsx | 2 +- .../test/InfoTooltipWithTrigger.test.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx index 475396971f..cc69c80164 100644 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -52,7 +52,7 @@ export default function InfoTooltipWithTrigger({ onKeyPress={ onClick && ((event: React.KeyboardEvent) => { - if (event.key === 'Enter' || event.key === 'space') { + if (event.code === 'Enter' || event.code === 'Space') { onClick(); } }) diff --git a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx index 93888a6dac..9b331e9f33 100644 --- a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx +++ b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx @@ -19,11 +19,11 @@ describe('InfoTooltipWithTrigger', () => { const wrapper = shallow( , ); - wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Tab' }); + wrapper.find('.fa-info-circle').simulate('keypress', { code: 'Tab' }); expect(clickHandler).toHaveBeenCalledTimes(0); - wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Enter' }); + wrapper.find('.fa-info-circle').simulate('keypress', { code: 'Enter' }); expect(clickHandler).toHaveBeenCalledTimes(1); - wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Space' }); + wrapper.find('.fa-info-circle').simulate('keypress', { code: 'Space' }); expect(clickHandler).toHaveBeenCalledTimes(2); }); From 1c4be6215df47e62869efb4341fae2676c0ffe09 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian Date: Thu, 7 May 2020 10:29:50 -0700 Subject: [PATCH 13/13] ugh fine --- .../src/InfoTooltipWithTrigger.tsx | 2 +- .../test/InfoTooltipWithTrigger.test.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx index cc69c80164..77f6658e94 100644 --- a/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx +++ b/packages/superset-ui-control-utils/src/InfoTooltipWithTrigger.tsx @@ -52,7 +52,7 @@ export default function InfoTooltipWithTrigger({ onKeyPress={ onClick && ((event: React.KeyboardEvent) => { - if (event.code === 'Enter' || event.code === 'Space') { + if (event.key === 'Enter' || event.key === ' ') { onClick(); } }) diff --git a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx index 9b331e9f33..b4f85a8120 100644 --- a/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx +++ b/packages/superset-ui-control-utils/test/InfoTooltipWithTrigger.test.tsx @@ -19,11 +19,11 @@ describe('InfoTooltipWithTrigger', () => { const wrapper = shallow( , ); - wrapper.find('.fa-info-circle').simulate('keypress', { code: 'Tab' }); + wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Tab' }); expect(clickHandler).toHaveBeenCalledTimes(0); - wrapper.find('.fa-info-circle').simulate('keypress', { code: 'Enter' }); + wrapper.find('.fa-info-circle').simulate('keypress', { key: 'Enter' }); expect(clickHandler).toHaveBeenCalledTimes(1); - wrapper.find('.fa-info-circle').simulate('keypress', { code: 'Space' }); + wrapper.find('.fa-info-circle').simulate('keypress', { key: ' ' }); expect(clickHandler).toHaveBeenCalledTimes(2); });