Skip to content

add option to enable / disable autofocus of input when a button is clicked#456

Closed
macrozone wants to merge 1 commit intomicrosoft:masterfrom
panter:feature/allow-to-disable-auto-focus-on-button-click
Closed

add option to enable / disable autofocus of input when a button is clicked#456
macrozone wants to merge 1 commit intomicrosoft:masterfrom
panter:feature/allow-to-disable-auto-focus-on-button-click

Conversation

@macrozone
Copy link
Copy Markdown
Contributor

@macrozone macrozone commented May 10, 2017

if a user clicks on a card button, the input get focused, which opens the keyboard on mobile device.
This can be annoying if you use a lot of confirms and choices.

you can now set setFocusOnCardActionClick to false on the <Chat>-Component to disable this behaviour.

The caveat is that the chat no longer scrolls to bottom, when a button is clicked when this option is false.

Feedback welcome!

@msftclas
Copy link
Copy Markdown

@macrozone,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@msftclas
Copy link
Copy Markdown

@macrozone, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, Microsoft Pull Request Bot

Comment thread src/History.tsx

private doCardAction(type: CardActionTypes, value: string) {
this.props.setFocus();
if(this.props.setFocusOnCardActionClick) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this conditional can be moved above

Comment thread src/Chat.tsx
<MessagePane setFocus={ () => this.setFocus() }>
<History setFocus={ () => this.setFocus() }/>
<History
setFocusOnCardActionClick={this.props.setFocusOnCardActionClick}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add the conditional here, we won't need the additional property on History

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought about that, but from looking at this piece of code, you don't know whether History might need this.setFocus for someting else. That's why I dediced to use a rather verbose property that does exactly what it says.

@billba
Copy link
Copy Markdown
Member

billba commented May 12, 2017

I'm wary of introducing too many "behave this way" flags into properties. Is there really no best practice on how to handle this?

@danmarshall
Copy link
Copy Markdown
Contributor

I have a few ideas on how we might re-implement this feature, can we discuss on the original issue? #363

@macrozone
Copy link
Copy Markdown
Contributor Author

@danmarshall the original issue focuses more on desktop interaction, so maybe we should open another issue about the problems on mobile devices. What i would expect as user when clicking on a button (on mobile device):

  1. scroll to bottom
  2. do not open keyboard

My option prevents the keyboard from opening, but unfortunatly does not scroll down on button click anymore

@billba totally agree, it's a workaround and does not solve the underlying issue (scrolling down while not opening the keyboard)

@danmarshall
Copy link
Copy Markdown
Contributor

Hi @macrozone , we are going to revisit how we want to approach the features for autoscroll and focus. I'm going to close this PR for now, but thanks for the contribution!

@nupurkamble
Copy link
Copy Markdown

@macrozone hey I'm new to using bot and I want to disable the autofocus on input. i.e. i don't want the keyboard every time as it takes up too much space and the bot is barely visible. Can you please tell me how i can implement it in my bot. I've created a bot using .Net.

@macrozone
Copy link
Copy Markdown
Contributor Author

@nupurkamble I forked the project (node.js version) and added this option myself ;-) You will have to wait for the contributors to implement that functionallity.

Please follow this issue: #623

compulim pushed a commit to compulim/BotFramework-WebChat that referenced this pull request Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants