Skip to content

fix: Tooltip should not hide if an element inside it gets focused#25140

Merged
khmakoto merged 4 commits intomicrosoft:masterfrom
khmakoto:tooltipWithLink
Oct 7, 2022
Merged

fix: Tooltip should not hide if an element inside it gets focused#25140
khmakoto merged 4 commits intomicrosoft:masterfrom
khmakoto:tooltipWithLink

Conversation

@khmakoto
Copy link
Member

@khmakoto khmakoto commented Oct 7, 2022

Previous Behavior

If a Tooltip is triggered by focusing on the element within TooltipHost, and the Tooltip contains any interactable items, then trying to interact with these items within the Tooltip (for example, clicking on a link within it) will cause the Tooltip to close. This occurs because the Tooltip closes immediately on blur, which precedes other interactions like focus or click.

New Behavior

A 0ms timeout has been added before the Tooltip closes on blur, and a check has been added so that if anything within the Tooltip gets focus then the timeout is cleared. Because of the way that events queue on the browser, this ensures that we can always interact with content within the Tooltip before it closes on blur.

Related Issue(s)

Fixes #24054
Fixes #25001

PR #25138 fixes the same issue in v9+

@khmakoto khmakoto added Component: Tooltip Fluent UI react (v8) Issues about @fluentui/react (v8) labels Oct 7, 2022
@khmakoto khmakoto self-assigned this Oct 7, 2022
@khmakoto khmakoto requested review from a team and behowell as code owners October 7, 2022 22:05
@github-actions github-actions bot added this to the October Project Cycle Q4 2022 milestone Oct 7, 2022
@fabricteam
Copy link
Collaborator

fabricteam commented Oct 7, 2022

📊 Bundle size report

🤖 This report was generated against 223571d0a6317630a2c376d278c3e4a60c10e97a

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 7, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4178286:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@size-auditor
Copy link

size-auditor bot commented Oct 7, 2022

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react fluentui-react-CommandBar 190.473 kB 190.79 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-SelectedItemsList 220.032 kB 220.349 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-ColorPicker 123.811 kB 124.128 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-Facepile 199.32 kB 199.637 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-FloatingPicker 229.623 kB 229.94 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-Breadcrumb 189.409 kB 189.726 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-Persona 107.74 kB 108.057 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-Pickers 278.837 kB 279.154 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-PersonaCoin 107.74 kB 108.057 kB ExceedsBaseline     317 bytes
office-ui-fabric-react fluentui-react-Tooltip 80.326 kB 80.643 kB ExceedsBaseline     317 bytes

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

Baseline commit: 223571d0a6317630a2c376d278c3e4a60c10e97a (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Oct 7, 2022

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 1175 1211 5000
Breadcrumb mount 2985 3018 1000
Checkbox mount 2711 2702 5000
CheckboxBase mount 2288 2375 5000
ChoiceGroup mount 4400 4347 5000
ComboBox mount 1262 1289 1000
CommandBar mount 9582 9528 1000
ContextualMenu mount 11440 11022 1000
DefaultButton mount 1387 1421 5000
DetailsRow mount 3617 3605 5000
DetailsRowFast mount 3692 3647 5000
DetailsRowNoStyles mount 3491 3476 5000
Dialog mount 3087 3118 1000
DocumentCardTitle mount 580 591 1000
Dropdown mount 3255 3237 5000
FocusTrapZone mount 2025 2054 5000
FocusZone mount 2011 1992 5000
GroupedList mount 53879 61029 2
GroupedList virtual-rerender 25187 25106 2
GroupedList virtual-rerender-with-unmount 94380 95264 2
GroupedListV2 mount 575 572 2
GroupedListV2 virtual-rerender 547 536 2
GroupedListV2 virtual-rerender-with-unmount 562 575 2
IconButton mount 1862 2013 5000
Label mount 727 754 5000
Layer mount 4324 4275 5000
Link mount 837 841 5000
MenuButton mount 1682 1695 5000
MessageBar mount 2276 2279 5000
Nav mount 3293 3223 1000
OverflowSet mount 1372 1354 5000
Panel mount 2585 2603 1000
Persona mount 1263 1292 1000
Pivot mount 1653 1679 1000
PrimaryButton mount 1518 1524 5000
Rating mount 6927 6961 5000
SearchBox mount 1528 1534 5000
Shimmer mount 2889 2877 5000
Slider mount 2150 2101 5000
SpinButton mount 4719 4688 5000
Spinner mount 796 835 5000
SplitButton mount 3115 3135 5000
Stack mount 853 840 5000
StackWithIntrinsicChildren mount 2315 2365 5000
StackWithTextChildren mount 4731 4761 5000
SwatchColorPicker mount 10642 10539 5000
TagPicker mount 2759 2697 5000
TeachingBubble mount 90470 89833 5000
Text mount 803 786 5000
TextField mount 1539 1623 5000
ThemeProvider mount 1508 1512 5000
ThemeProvider virtual-rerender 1073 1093 5000
ThemeProvider virtual-rerender-with-unmount 2146 2140 5000
Toggle mount 1107 1142 5000
buttonNative mount 545 554 5000

directionalHintForRTL={directionalHintForRTL}
calloutProps={assign({}, calloutProps, {
onDismiss: this._hideTooltip,
onFocus: this._onTooltipContentFocus,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you also need onBlur to dismiss the tooltip when it loses focus (e.g. tabbing out of the tooltip after clicking the link)? Or is that handled by the callout already?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's handled by Callout already.

@khmakoto khmakoto merged commit f613922 into microsoft:master Oct 7, 2022
@khmakoto khmakoto deleted the tooltipWithLink branch October 7, 2022 23:53
marcosmoura added a commit to marcosmoura/fluentui that referenced this pull request Oct 10, 2022
* master: (23 commits)
  Revert "chore: screener-run workflow should report to PR (microsoft#25144)" (microsoft#25145)
  chore: screener-run workflow should report to PR (microsoft#25144)
  applying package updates
  fix: The Tooltip should not hide if it gets keyboard focus (microsoft#25138)
  fix: Tooltip should not hide if an element inside it gets focused (microsoft#25140)
  Create react-migration-v8-v9 with shims and stories (microsoft#25121)
  fix: CheckboxField to set a generated ID on the input, to match the label's htmlFor (microsoft#25079)
  feat: Overflow menu should be registered in overflowManager (microsoft#25091)
  fix: version-bump generator removes beachball disallowedChangeType config (microsoft#25130)
  fix: new overflow items should only be enqueued while observing (microsoft#25122)
  fix(script): allow runPublished call from CLI (microsoft#25127)
  feat: add vertical variation for toolbar (microsoft#24940)
  ProgressField implementation and stories (microsoft#25103)
  fix: Dropdown icon layout with no placeholder/value (microsoft#25049)
  chore: add a bundle size fixture (Button, Provider & theme) (microsoft#25113)
  feat: Adding subtle transition between states on Button components (microsoft#25106)
  Revert "chore: screener-run workflow should report to PR (microsoft#25096)" (microsoft#25115)
  chore: screener-run workflow should report to PR (microsoft#25096)
  fix(react-dialog): aria-* properties should be reassignable (microsoft#25092)
  fix(scripts): don't run publish if web-components are affected (microsoft#25095)
  ...
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
…crosoft#25140)

* fix: Tooltip should not hide if an element inside it gets focused.

* Adding change fil.

* Changing delay on blur from 1ms to 0ms.

* Removing changes in Tooltip example.

Co-authored-by: Humberto Makoto Morimoto Burgos <makotom@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Tooltip Fluent UI react (v8) Issues about @fluentui/react (v8)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not being able to click on multiple buttons in tooltip[Bug]: [Bug]: [Tooltip][React] Link in tooltip on mobile browsers doesn't work

3 participants