Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input action does not work #2003

Closed
philr35 opened this issue Aug 25, 2017 · 5 comments
Closed

Input action does not work #2003

philr35 opened this issue Aug 25, 2017 · 5 comments
Labels

Comments

@philr35
Copy link

philr35 commented Aug 25, 2017

Steps to Reproduce
From your documentation from the Inputs section under the "actions" header. The code for copy input to clipboard does not work

Documentation: https://react.semantic-ui.com/elements/input#input-example-action-labeled-button

Expected
When button is clicked, user should expect input is copied into their clipboard and should be able to paste elsewhere

Result
Nothing happens on button click. Nothing is copied into clipboard.

Version
0.71.3

Testcase
Here is the test case that shows the issue: https://codepen.io/philliprognerud/pen/OjwBBv

@philr35 philr35 changed the title fix(Input): your description fix(Input): Input action does not work Aug 25, 2017
@philr35 philr35 changed the title fix(Input): Input action does not work Input action does not work Aug 25, 2017
@layershifter
Copy link
Member

The main idea of this example is to show example markup and way to generate it, it should not be fully functional. For copy text you can you onClick handler and copy-to-clipboard package.

@rhapi
Copy link

rhapi commented Nov 28, 2017

To handle click, you need to create your custom "action" button.
<Input action={ <Button color='teal' icon='copy' content='Copy' onClick={ handleClick } />} defaultValue='Test input does not copy' style={{padding: "50px"}} />
This code works : https://codepen.io/anon/pen/VrGVob

@martisj
Copy link

martisj commented Dec 11, 2017

@rhapi You don't need to create a "custom" action button. Seems like you can include an onClick inside the action parameter like so:
<Input action={{ color: 'teal', icon: 'copy', onClick: (e) => {handleClick} }} />

@levithomason
Copy link
Member

For clarity, all shorthand props (like action) accept strings, numbers, props objects, or elements:

<Input action='My Action' />
<Input action={123} />
<Input action={{ content: 'My Action', onClick: this.handleClick }} />
<Input action={<Button content='My Action' onClick={this.handleClick} />} />

In all cases, the shorthand prop creates a new element. This API and behavior are the same for all shorthand props on all components.

@brianespinosa
Copy link
Member

The example above is one we should include in the shorthand docs for #561

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants