Skip to content

Commit

Permalink
Storybook test 변경했다
Browse files Browse the repository at this point in the history
  • Loading branch information
healtheloper committed Oct 12, 2023
1 parent 698c80c commit 2f2a906
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import React, { useState } from 'react';
import { Tooltip } from '../../Tooltip';
import { Input } from '../Input';
import { Modal } from '../../Modal';

export default {
title: '@co-design/core/Input',
Expand Down Expand Up @@ -116,12 +117,25 @@ export const WithLabel = {
},
};

// Storybook Context 변경으로 인한 리렌더링으로 focus 풀림
export const AutoFocus = {
render: (props) => {
const [opened, setOpened] = useState(false);
return (
<div style={{ width: 400, padding: 24 }}>
<Input autoFocus {...props} />
</div>
<>
<div style={{ width: 400, padding: 24 }}>
<button
onClick={() => {
setOpened(true);
}}
>
open modal
</button>
</div>
<Modal opened={opened} onClose={() => setOpened(false)}>
<Input autoFocus {...props} />
</Modal>
</>
);
},
};

0 comments on commit 2f2a906

Please sign in to comment.