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

Issue 549 #571

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Issue 549 #571

wants to merge 6 commits into from

Conversation

meaagan
Copy link

@meaagan meaagan commented Nov 8, 2021

Issue #549: hide_after should work without show_on: 'event'

Hi! As you can see, this PR only consists of a bunch of console.logs and puts. I did this to show where I was looking for the bug/solution and to potentially get a hint on where to start. I was (obviously) unsuccessful, but I am hoping that I was looking at the correct lines or at least in the right files.

I understand that the issue comes from the mount as it says in the description of the bug (the lifecycle is never started, therefore the timer also never starts), but knowing that it comes from a vue.js file, I could not figure out what to do.

@meaagan meaagan changed the title Console.logs/puts Issue 549 Nov 8, 2021
@pascalwengerter
Copy link
Contributor

Hey, thanks for opening this PR! I'm not overly familiar with the codebase anymore, but from what I've gathered from a quick skimming, could you try the following in https://github.com/matestack/matestack-ui-core/blob/19b5b8c97ee551d8d2f80840aa2d1c16a5727e9e/lib/matestack/ui/vue_js/components/toggle.js ?

Put this code snippet from the show method

      if(this.props["hide_after"] != undefined){
        self.hide_after_timeout = setTimeout(function () {
          self.hide()
        }, parseInt(this.props["hide_after"]));
      }

into the created function of the toggle component?

Also, line 46-48 of this component can be safely deleted from my POV since they already get covered in line 37-38

@pascalwengerter
Copy link
Contributor

Elaboration: The way I read the issue, the toggle component misses some sort of awareness about its hide_after configuration, and since all the other props get checked in the created function I came up with the reasoning above. Maybe @jonasjabari can take a look and clarify?

@meaagan
Copy link
Author

meaagan commented Nov 9, 2021

@pascalwengerter Wow thanks for commenting so quickly! I tried out your solution with no success last night, but I do think it's close. I tried a few other things based on your solution with again, no success, but I will keep trying. Thanks again!

Copy link
Contributor

@pascalwengerter pascalwengerter left a comment

Choose a reason for hiding this comment

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

Maybe I need to setup Ruby/Rails/matestack on my machine as well to get my hands dirty on this 👨🏽‍🔬 just some quick review of your changes since I got the notification

@@ -39,6 +39,11 @@ const componentDef = {
hide: function(){
this.showing = false
this.event.data = {}
if(this.props["hide_after"] != undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you'll have to touch this component though, the hide method is already called in a timeout in line 35 if hide_after is defined

Copy link
Member

Choose a reason for hiding this comment

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

Yes this component does not need to be touched. The hide things in the async component should actually be deleted at some point...

@@ -7,7 +7,7 @@ const componentDef = {
data: function(){
return {
showing: true,
hide_after_timeout: null,
hideAfterTimeout: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to rename this from my POV, but if you want to then please do so in the rest of the file as well ;)

@jonasjabari
Copy link
Member

Hey @meaagan @pascalwengerter!

Sorry for my late reply on this one! And thanks a lot @meaagan for your PR! I agree with @pascalwengerter suggestion:

Put this code snippet from the show method

      if(this.props["hide_after"] != undefined){
        self.hide_after_timeout = setTimeout(function () {
          self.hide()
        }, parseInt(this.props["hide_after"]));
      }

into the created function of the toggle component?

Also, line 46-48 of this component can be safely deleted from my POV since they already get covered in line 37-38

show_on and hide_after should work independently from each other:

  • Using only show_on should show the content on an event

  • Using shown_on and hide_after together should (like currently working) show the content on an event and from then on start a timer in order to hide the content again after the specified time

  • Using only hide_after should hide the content after mount in a specified time

With the suggested addition of @pascalwengerter, a combination of show_on and hide_after would work. The content is not visible at the beginning and the hider_after timer is started. After the given time, the timer would trigger hiding the content, but it's already hidden. That's ok IMO. The time is then again triggered when the specified event is emitted. So that behavior would still work. But we should add a clearTimeout (the one from the destroy hook) every time the show event is emitted. Otherwise the initial timer triggered on mount and the one triggered from the show method might "conflict"

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

Successfully merging this pull request may close these issues.

None yet

3 participants