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

Select the first application frame by default #48

Closed
bernardofbbragameli opened this issue Dec 8, 2022 · 1 comment
Closed

Select the first application frame by default #48

bernardofbbragameli opened this issue Dec 8, 2022 · 1 comment

Comments

@bernardofbbragameli
Copy link

Package version

3.2.2

Describe the bug

The frame that is selected by default is always the first (index=0) https://github.com/poppinss/youch/blob/develop/src/Youch.js#L136-L138

However, the selected frame should be the first application frame, to better inform the user where they can change the code.

In case the error is thrown internally by some npm library, the selected frame is not the application frame, but the library frame (even if "show all frames" is not active). That means a hidden frame is selected.

Reproduction repo

No response

@bernardofbbragameli
Copy link
Author

bernardofbbragameli commented Dec 8, 2022

I've been able to work around this bug by doing this to the youch response:

const response = html.replace('</body>',
        `<script type="text/javascript">
          const f = document.querySelector('.frames-list').children;
          for(let i=0; i<f.length; i++){
            const classList = f[i].classList;
            let found = true;
            for(let j=0; j<classList.length; j++){
              if(classList[j]==="native-frame") found = false;
            }
            if(found){
              document.addEventListener('DOMContentLoaded',()=>{
                f[i].click();
              })
              break;
            }
          }
        </script>
        </body>
        `);

however it seems to me that this should be the default

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

No branches or pull requests

2 participants