You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2019/07/03 22:05:59 UTC
[incubator-superset] branch master updated: [dashboard] Fix
URLShortLinkButton position after click anchor link (#7812)
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 9b89960 [dashboard] Fix URLShortLinkButton position after click anchor link (#7812)
9b89960 is described below
commit 9b8996038e0ff02f8902cdb8e1822d8000f79210
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Wed Jul 3 15:05:51 2019 -0700
[dashboard] Fix URLShortLinkButton position after click anchor link (#7812)
---
.../dashboard/components/gridComponents/Tabs_spec.jsx | 11 +++++++++++
superset/assets/src/components/AnchorLink.jsx | 10 ----------
superset/assets/src/components/URLShortLinkButton.jsx | 4 ++--
.../assets/src/dashboard/components/gridComponents/Tabs.jsx | 9 ++++++++-
4 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/superset/assets/spec/javascripts/dashboard/components/gridComponents/Tabs_spec.jsx b/superset/assets/spec/javascripts/dashboard/components/gridComponents/Tabs_spec.jsx
index 72d3a03..9cb81e6 100644
--- a/superset/assets/spec/javascripts/dashboard/components/gridComponents/Tabs_spec.jsx
+++ b/superset/assets/spec/javascripts/dashboard/components/gridComponents/Tabs_spec.jsx
@@ -131,6 +131,17 @@ describe('Tabs', () => {
expect(onChangeTab.callCount).toBe(1);
});
+ it('should not call onChangeTab when anchor link is clicked', () => {
+ const onChangeTab = sinon.spy();
+ const wrapper = setup({ editMode: true, onChangeTab });
+ wrapper
+ .find('.dashboard-component-tabs .nav-tabs a .short-link-trigger')
+ .at(1) // will not call if it is already selected
+ .simulate('click');
+
+ expect(onChangeTab.callCount).toBe(0);
+ });
+
it('should render a HoverMenu in editMode', () => {
let wrapper = setup();
expect(wrapper.find(HoverMenu)).toHaveLength(0);
diff --git a/superset/assets/src/components/AnchorLink.jsx b/superset/assets/src/components/AnchorLink.jsx
index dac5e25..c21bb4b 100644
--- a/superset/assets/src/components/AnchorLink.jsx
+++ b/superset/assets/src/components/AnchorLink.jsx
@@ -38,11 +38,6 @@ const defaultProps = {
class AnchorLink extends React.PureComponent {
- constructor(props) {
- super(props);
-
- this.handleClickAnchorLink = this.handleClickAnchorLink.bind(this);
- }
componentDidMount() {
const hash = this.getLocationHash();
@@ -65,17 +60,12 @@ class AnchorLink extends React.PureComponent {
return (window.location.hash || '').substring(1);
}
- handleClickAnchorLink(ev) {
- ev.stopPropagation();
- }
-
render() {
const { anchorLinkId, filters, showShortLinkButton, placement } = this.props;
return (
<span
className="anchor-link-container"
id={anchorLinkId}
- onClick={this.handleClickAnchorLink}
>
{showShortLinkButton &&
<URLShortLinkButton
diff --git a/superset/assets/src/components/URLShortLinkButton.jsx b/superset/assets/src/components/URLShortLinkButton.jsx
index d6d6c16..2dfc0f9 100644
--- a/superset/assets/src/components/URLShortLinkButton.jsx
+++ b/superset/assets/src/components/URLShortLinkButton.jsx
@@ -78,8 +78,8 @@ class URLShortLinkButton extends React.Component {
onEnter={this.getCopyUrl}
overlay={this.renderPopover()}
>
- <span className="btn btn-default btn-sm" data-test="short-link-button">
- <i className="fa fa-link" />
+ <span className="short-link-trigger btn btn-default btn-sm" data-test="short-link-button">
+ <i className="short-link-trigger fa fa-link" />
</span>
</OverlayTrigger>
);
diff --git a/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx b/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx
index d00df3a..ce40b53 100644
--- a/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx
+++ b/superset/assets/src/dashboard/components/gridComponents/Tabs.jsx
@@ -100,7 +100,14 @@ class Tabs extends React.PureComponent {
}
}
- handleClickTab(tabIndex) {
+ handleClickTab(tabIndex, ev) {
+ const target = ev.target;
+ // special handler for clicking on anchor link icon (or whitespace nearby):
+ // will show short link popover but do not change tab
+ if (target.classList.contains('short-link-trigger')) {
+ return;
+ }
+
const { component, createComponent } = this.props;
if (tabIndex === NEW_TAB_INDEX) {