Exposing the maxContentSizeMultiplier prop for RN.Text and RN.TextInput.#78
Exposing the maxContentSizeMultiplier prop for RN.Text and RN.TextInput.#78berickson1 merged 23 commits intomicrosoft:masterfrom rumit91:rumit91/fontScalingLimit
Conversation
…with minimumFontScale.
|
@rumit91, |
package.json
Outdated
| "react-addons-test-utils": "^15.4.1", | ||
| "react-dom": "^15.4.1", | ||
| "react-native": "^0.42.0", | ||
| "react-native": "git+https://skype.visualstudio.com/DefaultCollection/TPS/_git/react-native#timale/fontScalingLimit", |
There was a problem hiding this comment.
You can't change the public reactxp to point to a private, internal react-native version. Just leave the version as-is. Internally, the Skype repo can refer to the private react-native branch.
There was a problem hiding this comment.
Yep will remove for sure. Was just using this for testing.
src/android/Text.tsx
Outdated
| importantForAccessibility={ importantForAccessibility } | ||
| numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | ||
| allowFontScaling={ this.props.allowFontScaling } | ||
| maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
Why wouldn't we also expose a minFontSizeMultiplier?
There was a problem hiding this comment.
I didn't add a min, because the user changing the system font to the minimum didn't seem to cause any issues in RN apps, but do you think it would still be valuable for me to add?
src/android/Text.tsx
Outdated
| AccessibilityUtil.setAccessibilityFocus(this); | ||
| } | ||
|
|
||
| static setDefaultMaxFontSizeMultiplier(maxFontSizeMultiplier: number): void { |
There was a problem hiding this comment.
This shouldn't be exposed as a static method on Text. It should be a method on the UserInterface namespace.
There was a problem hiding this comment.
Moved to UserInterface.
src/android/Text.tsx
Outdated
| importantForAccessibility={ importantForAccessibility } | ||
| numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | ||
| allowFontScaling={ this.props.allowFontScaling } | ||
| maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
For consistency with UserInterface (and react native) terminology, this should be called maxContentSizeMultiplier, not minFontSizeMultiplier.
There was a problem hiding this comment.
Changed the var name.
src/android/Text.tsx
Outdated
| importantForAccessibility={ importantForAccessibility } | ||
| numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | ||
| allowFontScaling={ this.props.allowFontScaling } | ||
| maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
Do we really need to expose an override of the default max on a per-Text basis? This seems like it might be overkill.
There was a problem hiding this comment.
I think we need this to be able to override the default in specific instances. For example, we may want the maxContentSizeMultiplier to be much higher for text inside message bubbles vs the text in the navigational elements.
src/native-common/TextInput.tsx
Outdated
| this._onChangeText(value); | ||
| } | ||
|
|
||
| static setDefaultMaxFontSizeMultiplier(maxFontSizeMultiplier: number): void { |
There was a problem hiding this comment.
I don't think we need a different default for Text and TextInput. As mentioned above, this should be collapsed to a single API - UserInterface.setDefaultMaxContentSizeMultiplier.
There was a problem hiding this comment.
Agreed. Moved to UserInterface.
src/android/Text.tsx
Outdated
| importantForAccessibility={ importantForAccessibility } | ||
| numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | ||
| allowFontScaling={ this.props.allowFontScaling } | ||
| maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
The documentation for Text, TextInput and UserInterface need to be updated as well.
There was a problem hiding this comment.
Thanks for reminding me. I added the docs.
…Added `maxContentSizeMultiplier` to Link.
…tly not available in most version of RN.
docs/docs/apis/userinterface.md
Outdated
|
|
||
| // Triggered when the max content size multiplier changes while | ||
| // the app is running. | ||
| maxContentSizeMultiplierChangedEvent: SubscribableEvent< |
There was a problem hiding this comment.
We don't need this event. The max content size multiplier is under the control of the app, so it can track this change itself. The reason I added an event for contentSizeMultiplierChanged is that it's under control of the OS (and ultimately the user), so the app needs to be informed when it changes.
There was a problem hiding this comment.
Removed from the code and the docs.
docs/docs/components/text.md
Outdated
| // Should the scale multiplier be capped when allowFontScaling is set to true? | ||
| // The default of 0 indicates that the compoent should obey the global setting | ||
| // in UserInterface which by default is uncapped. | ||
| // Note: Most versions of React Native don’t support this interface. |
docs/docs/components/textinput.md
Outdated
| // Should the scale multiplier be capped when allowFontScaling is set to true? | ||
| // The default of 0 indicates that the compoent should obey the global setting | ||
| // in UserInterface which by default is uncapped. | ||
| // Note: Most versions of React Native don’t support this interface. |
docs/docs/components/link.md
Outdated
| // Should the scale multiplier be capped when allowFontScaling is set to true? | ||
| // The default of 0 indicates that the compoent should obey the global setting | ||
| // in UserInterface which by default is uncapped. | ||
| // Note: Most versions of React Native don’t support this interface. |
There was a problem hiding this comment.
Rather than saying "Most versions of React Native", please change to "Older versions...".
src/android/Text.tsx
Outdated
| </RN.Text> | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
Did you intend to delete this, or was it a merge error? Amay recently added this code.
There was a problem hiding this comment.
I deleted it because it caused merge conflicts. I believe Amay removed it from master recently with this commit: cff4b51
erictraut
left a comment
There was a problem hiding this comment.
When you're ready to merge this, let DDR or Brent know, and they can merge and republish.
…ut. (microsoft#78) * Exposed the maximumFontScale prop and updating docs
Whenever a user changes the system font size to its maximum allowable setting most React Native apps that allow font scaling become unusable. Ideally React Native apps would mimic the behavior of the iMessage (iOS) app where the font size used for non-body text (header, navigational elements, etc) is capped while the body text (text in the message bubbles) is allowed to grow. In this PR I expose the
maxContentSizeMultiplierprop on<Text>,<TextInput>, and<Link>. Developers can overwrite the default maxContentSizeMultiplier by calling the static methodUserInterface. setMaxContentSizeMultiplier()or they can just choose to set themaxContentSizeMultiplieron the desired elements.