fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Should Coachmark render on ComponentMount?

Open gbminnock opened this issue 7 years ago • 6 comments

Apologies if I have categorized this incorrectly as I am not sure if I have misunderstood the purpose of Coachmark or I am using it incorrectly.


Requirement: Load the coachmark once the component has mount (without any user interaction).

In the sample below I load a button and want the coachmark to show once rendered. I cannot seem to get it to render at all.

Codepen

Tks, Gary

gbminnock avatar Dec 08 '18 15:12 gbminnock

The reason why Coachmark does not render on component mount is because it still doesn't have access to its target since the DOM is not loaded yet. Therefore, target is null at the time PositioningContainer is rendered, opacity is 0 and the position is not set. A workaround for this (not the best solution but a simple one for demonstration) is to set a timeout in componentDidMount and do a forceUpdate to have the Coachmark appear once the DOM is loaded.

The example you provided modified to do this can be found in the following codepen.

Please let me know if this doesn't work so I can provide further assistance as necessary.

khmakoto avatar Dec 10 '18 21:12 khmakoto

Super thanks @khmakoto. In an ideal situation should the Coachmark be used in conjunction with a user action trigger? I envisioned the Coachmark drawing attention to something once the user has loaded the page/screen.

gbminnock avatar Dec 11 '18 21:12 gbminnock

You're welcome!

And ideally yes, the Coachmark should be used in conjunction with a user interaction to draw attention to the target, which is the way in which the component was designed. It can be, however, tweaked to perform on page/screen load as said before. In the end it all depends on how you want to use it and if it makes sense to use the component that way :)

khmakoto avatar Dec 11 '18 21:12 khmakoto

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fabric React!

msft-github-bot avatar Dec 15 '18 22:12 msft-github-bot

Ok, thanks for the information

gbminnock avatar Dec 19 '18 19:12 gbminnock

@khmakoto Thanks for information. Below is my case When the user clicks on a button CoachMark is popping up and on mouse over to this CoachMark, TeachingBubbleContent is displaying. Is there a way the TeachingBubbleContent can be displayed automatically after some seconds instead of mouse over? Thanks!

NavaneethaDev avatar Jan 11 '19 21:01 NavaneethaDev