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

Fabric: Properly handle dir being passed into control #11626

Merged
merged 9 commits into from Jan 13, 2020
Merged

Fabric: Properly handle dir being passed into control #11626

merged 9 commits into from Jan 13, 2020

Conversation

micahgodbolt
Copy link
Member

@micahgodbolt micahgodbolt commented Jan 7, 2020

Pull request checklist

Description of changes

Earlier Fabric component update set direction: rtl based off of the theme alone. This update will look first to the dir attribute (if provided), and then look to the theme.rtl (if provided) before setting dir attribute of the Fabric component.

Updated tests as well.

Focus areas to test

(optional)

Microsoft Reviewers: Open in CodeFlow

@micahgodbolt micahgodbolt changed the title Fabric theme rtl fix Fabric: Properly handle dir being passed into control Jan 7, 2020
@micahgodbolt micahgodbolt reopened this Jan 7, 2020
@msft-github-bot
Copy link
Contributor

msft-github-bot commented Jan 7, 2020

Component Perf Analysis

No significant results to display.

All results

Scenario Master Ticks PR Ticks Status
BaseButton 673 700
BaseButton (experiments) 949 908
DefaultButton 979 1017
DefaultButton (experiments) 1886 1850
DetailsRow 3198 3254
DetailsRow (fast icons) 3299 3436
DetailsRow without styles 3001 3101
DocumentCardTitle with truncation 1457 1469
MenuButton 1344 1354
MenuButton (experiments) 3361 3534
PrimaryButton 1139 1186
PrimaryButton (experiments) 1983 2012
SplitButton 2755 2745
SplitButton (experiments) 6792 6989
Stack 463 474
Stack with Intrinsic children 1057 1074
Stack with Text children 4201 4229
Text 361 433
Toggle 778 803
Toggle (experiments) 2191 2182
button 52 53

@micahgodbolt
Copy link
Member Author

@dzearing are you good with this change?

const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(this.props, divProperties, ['dir']);
// If dir is set via props, use that value, otherwise if theme is set, use theme RTL setting, otherwise, set undefined.
const htmlDir =
dir !== undefined ? dir : theme !== undefined && theme.rtl !== undefined ? (theme.rtl === true ? 'rtl' : 'ltr') : undefined;
Copy link
Member

@dzearing dzearing Jan 10, 2020

Choose a reason for hiding this comment

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

minor nit but I think this could be a little more readable:

const themeDir = (theme && theme.rtl) ? 'rtl' : 'ltr';
const htmlDir = dir !== undefined ? dir : themeDir;

Copy link
Member

@dzearing dzearing left a comment

Choose a reason for hiding this comment

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

minor nit.

@micahgodbolt
Copy link
Member Author

per david's suggestion, the dir logic is a bit more simple and will always return RTL or LTR for a Fabric component.

@size-auditor
Copy link

size-auditor bot commented Jan 10, 2020

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react Fabric 42.403 kB 42.459 kB ExceedsBaseline     56 bytes
office-ui-fabric-react Layer 47.821 kB 47.876 kB ExceedsBaseline     55 bytes
office-ui-fabric-react PositioningContainer 72.941 kB 72.995 kB ExceedsBaseline     54 bytes
office-ui-fabric-react Pivot 172.72 kB 172.773 kB ExceedsBaseline     53 bytes
office-ui-fabric-react SearchBox 173.89 kB 173.943 kB ExceedsBaseline     53 bytes
office-ui-fabric-react DocumentCard 200.97 kB 201.023 kB ExceedsBaseline     53 bytes
office-ui-fabric-react MessageBar 175.565 kB 175.618 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Modal 92.316 kB 92.369 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Tooltip 81.541 kB 81.594 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Dialog 193.834 kB 193.887 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Persona 115.281 kB 115.334 kB ExceedsBaseline     53 bytes
office-ui-fabric-react PersonaCoin 115.281 kB 115.334 kB ExceedsBaseline     53 bytes
office-ui-fabric-react DetailsList 209.197 kB 209.25 kB ExceedsBaseline     53 bytes
office-ui-fabric-react DatePicker 202.11 kB 202.163 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Grid 167.448 kB 167.501 kB ExceedsBaseline     53 bytes
office-ui-fabric-react ContextualMenu 147.215 kB 147.268 kB ExceedsBaseline     53 bytes
office-ui-fabric-react CommandBar 186.6 kB 186.653 kB ExceedsBaseline     53 bytes
office-ui-fabric-react ComboBox 228.95 kB 229.003 kB ExceedsBaseline     53 bytes
office-ui-fabric-react KeytipLayer 99.514 kB 99.567 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Dropdown 216.596 kB 216.649 kB ExceedsBaseline     53 bytes
office-ui-fabric-react HoverCard 96.411 kB 96.464 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Breadcrumb 184.907 kB 184.96 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Coachmark 94.119 kB 94.172 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Keytip 77.184 kB 77.237 kB ExceedsBaseline     53 bytes
office-ui-fabric-react FloatingPicker 224.981 kB 225.034 kB ExceedsBaseline     53 bytes
office-ui-fabric-react ShimmeredDetailsList 219.725 kB 219.778 kB ExceedsBaseline     53 bytes
office-ui-fabric-react TeachingBubble 190.808 kB 190.861 kB ExceedsBaseline     53 bytes
office-ui-fabric-react SwatchColorPicker 177.592 kB 177.645 kB ExceedsBaseline     53 bytes
office-ui-fabric-react SelectedItemsList 215.122 kB 215.175 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Callout 81.379 kB 81.432 kB ExceedsBaseline     53 bytes
office-ui-fabric-react Nav 174.197 kB 174.249 kB ExceedsBaseline     52 bytes
office-ui-fabric-react Button 179.929 kB 179.981 kB ExceedsBaseline     52 bytes
office-ui-fabric-react Facepile 196.406 kB 196.458 kB ExceedsBaseline     52 bytes
office-ui-fabric-react Panel 185.165 kB 185.217 kB ExceedsBaseline     52 bytes
office-ui-fabric-react Pickers 268.061 kB 268.113 kB ExceedsBaseline     52 bytes
office-ui-fabric-react SpinButton 179.102 kB 179.154 kB ExceedsBaseline     52 bytes

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: 61d9d19cb20855cc6d2930a4764ff397a3cf1bc4 (build)

@micahgodbolt
Copy link
Member Author

micahgodbolt commented Jan 10, 2020

had to do a bit more work to account for page level RTL (which does not affect theme). Reworked a bit of my and Davids Customizer logic to be a bit easier to follow.

Specifically here: https://github.com/OfficeDev/office-ui-fabric-react/pull/11626/files#diff-3b229796dd0781151c4cb54697913f02R21

Copy link
Contributor

@aneeshack4 aneeshack4 left a comment

Choose a reason for hiding this comment

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

Looks like the snaps just need to be updated

@dzearing dzearing merged commit 404a969 into microsoft:master Jan 13, 2020
@micahgodbolt micahgodbolt deleted the fabric-theme-rtl-fix branch January 13, 2020 16:37
@msft-github-bot
Copy link
Contributor

🎉office-ui-fabric-react@v7.82.0 has been released which incorporates this pull request.:tada:

Handy links:

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

Successfully merging this pull request may close these issues.

None yet

5 participants