Skip to content

Commit

Permalink
fix(Balloon): autoFocus should be false when triggerType is focus
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Apr 26, 2019
1 parent 118f851 commit af7cce1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 18 additions & 1 deletion docs/balloon/demo/triggerType.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ Hover, focus and click.
---

````jsx
import { Button, Balloon } from '@alifd/next';
import { Button, Balloon, Input } from '@alifd/next';


const content = (<div><p>content</p></div>);
const MoveTarget = <Button style={{margin: '5px'}}>hover</Button>;
const ClickTarget = <Button style={{margin: '5px'}}>click</Button>;
const FocusTarget = <Button style={{margin: '5px'}}>focus</Button>;

const HoverInputTarget = <Input placeholder="hover" style={{marginRight: '20px'}}/>;
const ClickInputTarget = <Input placeholder="click" style={{marginRight: '20px'}}/>;
const FocusInputTarget = <Input placeholder="focus" />;

const App = () => (
<div>
<Balloon trigger={MoveTarget} triggerType="hover">
Expand All @@ -37,6 +41,19 @@ const App = () => (
<Balloon trigger={FocusTarget} triggerType="focus">
{content}
</Balloon>

<br/>
<br/>

<Balloon trigger={HoverInputTarget} triggerType="hover">
{content}
</Balloon>
<Balloon trigger={ClickInputTarget} triggerType="click">
{content}
</Balloon>
<Balloon trigger={FocusInputTarget} triggerType="focus">
{content}
</Balloon>
</div>
);

Expand Down
2 changes: 1 addition & 1 deletion src/balloon/balloon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export default class Balloon extends React.Component {
needAdjust={needAdjust}
animation={animation}
delay={delay}
autoFocus={autoFocus}
autoFocus={triggerType === 'focus' ? false : autoFocus}
safeNode={safeNode}
container={popupContainer || container}
className={popupClassName}
Expand Down
2 changes: 2 additions & 0 deletions src/balloon/tooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default class Tooltip extends React.Component {
popupClassName,
popupStyle,
triggerType,
autoFocus,
rtl,
...others
} = this.props;
Expand Down Expand Up @@ -163,6 +164,7 @@ export default class Tooltip extends React.Component {
className={popupClassName}
style={popupStyle}
rtl={rtl}
autoFocus={triggerType === 'focus' ? false : autoFocus}
shouldUpdatePosition
{...popupProps}
>
Expand Down

0 comments on commit af7cce1

Please sign in to comment.