-
Notifications
You must be signed in to change notification settings - Fork 1.6k
add option to enable / disable autofocus of input when a button is clicked #456
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
Closed
macrozone
wants to merge
1
commit into
microsoft:master
from
panter:feature/allow-to-disable-auto-focus-on-button-click
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ export interface HistoryProps { | |
| onClickRetry: (activity: Activity) => void, | ||
|
|
||
| setFocus: () => void, | ||
| setFocusOnCardActionClick: boolean, | ||
|
|
||
| isFromMe: (activity: Activity) => boolean, | ||
| isSelected: (activity: Activity) => boolean, | ||
|
|
@@ -46,11 +47,11 @@ export class HistoryView extends React.Component<HistoryProps, {}> { | |
|
|
||
| // Subtract the padding from the offsetParent's width to get the width of the content | ||
| const maxContentWidth = (this.carouselActivity.messageDiv.offsetParent as HTMLElement).offsetWidth - paddedWidth; | ||
|
|
||
| // Subtract the content width from the chat width to get the margin. | ||
| // Next time we need to get the content width (on a resize) we can use this margin to get the maximum content width | ||
| const carouselMargin = this.props.size.width - maxContentWidth; | ||
|
|
||
| konsole.log('history measureMessage ' + carouselMargin); | ||
|
|
||
| // Finally, save it away in the Store, which will force another re-render | ||
|
|
@@ -71,10 +72,10 @@ export class HistoryView extends React.Component<HistoryProps, {}> { | |
| } | ||
|
|
||
| // In order to do their cool horizontal scrolling thing, Carousels need to know how wide they can be. | ||
| // So, at startup, we create this mock Carousel activity and measure it. | ||
| // So, at startup, we create this mock Carousel activity and measure it. | ||
| private measurableCarousel = () => | ||
| // find the largest possible message size by forcing a width larger than the chat itself | ||
| <WrappedActivity | ||
| <WrappedActivity | ||
| ref={ x => this.carouselActivity = x } | ||
| activity={ { | ||
| type: 'message', | ||
|
|
@@ -98,7 +99,9 @@ export class HistoryView extends React.Component<HistoryProps, {}> { | |
| // 3. (this is also the normal re-render case) To render without the mock activity | ||
|
|
||
| private doCardAction(type: CardActionTypes, value: string) { | ||
| this.props.setFocus(); | ||
| if(this.props.setFocusOnCardActionClick) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this conditional can be moved above |
||
| this.props.setFocus(); | ||
| } | ||
| return this.props.doCardAction(type, value); | ||
| } | ||
|
|
||
|
|
@@ -156,15 +159,15 @@ export const History = connect( | |
| format: state.format, | ||
| size: state.size, | ||
| activities: state.history.activities, | ||
| // only used to create helper functions below | ||
| // only used to create helper functions below | ||
| connectionSelectedActivity: state.connection.selectedActivity, | ||
| selectedActivity: state.history.selectedActivity, | ||
| botConnection: state.connection.botConnection, | ||
| user: state.connection.user | ||
| }), { | ||
| setMeasurements: (carouselMargin: number) => ({ type: 'Set_Measurements', carouselMargin }), | ||
| onClickRetry: (activity: Activity) => ({ type: 'Send_Message_Retry', clientActivityId: activity.channelData.clientActivityId }), | ||
| // only used to create helper functions below | ||
| // only used to create helper functions below | ||
| sendMessage | ||
| }, (stateProps: any, dispatchProps: any, ownProps: any): HistoryProps => ({ | ||
| // from stateProps | ||
|
|
@@ -176,6 +179,7 @@ export const History = connect( | |
| onClickRetry: dispatchProps.onClickRetry, | ||
| // from ownProps | ||
| setFocus: ownProps.setFocus, | ||
| setFocusOnCardActionClick: ownProps.setFocusOnCardActionClick, | ||
| // helper functions | ||
| doCardAction: doCardAction(stateProps.botConnection, stateProps.user, stateProps.format.locale, dispatchProps.sendMessage), | ||
| isFromMe: (activity: Activity) => activity.from.id === stateProps.user.id, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.