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

Sketch Welcome Screen #48

Closed
fabb opened this issue Apr 28, 2017 · 10 comments
Closed

Sketch Welcome Screen #48

fabb opened this issue Apr 28, 2017 · 10 comments

Comments

@fabb
Copy link

fabb commented Apr 28, 2017

Small bug when Sketch "Welcome" screen is shown on app start.

Expected behavior:

Rendering should start normally.

Observed behavior:

  • TypeError: null is not an object (evaluating 'context.document.currentPage')
  • Sketch shows welcome screen, but does not render document

How to reproduce:

Install Sketch and don't check off "show on every launch" on the "Welcome" screen.

Sketch version:

43.2

@alisonailea
Copy link

This is still happening to me even after turning off the Welcome Screen

@jemgold
Copy link
Contributor

jemgold commented Apr 28, 2017

Does it work if you open a blank document? We have no way of bypassing the Welcome Screen — I've mentioned it to @bomberstudios but we'd need Sketch to help us out :(

@fabb
Copy link
Author

fabb commented Apr 28, 2017

Does it work if you open a blank document?

Unfortunately not

@jemgold
Copy link
Contributor

jemgold commented Apr 28, 2017

Well that seems like a bigger issue :)

Can you try this?

  • Open Console.app (find it with Spotlight)
  • in the sidebar, select ~/Library/Logs -> com.bohemiancoding.sketch3 -> Plugin Output.log
  • Close & reopen Sketch
  • open a blank document
  • type npm run render in a terminal
  • are there any errors in your terminal, or in that Console screen?

@alisonailea
Copy link

Close & reopen Sketch
open a blank document
type npm run render in a terminal

That works! I got the styleguide example to load.

are there any errors in your terminal, or in that Console screen?

screen shot 2017-05-01 at 8 42 35 am

@vjpr
Copy link

vjpr commented Mar 25, 2018

Fixed by disabling welcome screen. This should be added to the getting started guide.

@macintoshhelper
Copy link
Contributor

macintoshhelper commented Apr 16, 2020

Hi, this seems to solve the issue and bypass the welcome screen:

const sketch = require('sketch');

export default () => {
  const documents = sketch.getDocuments();
  let doc = Array.isArray(documents) && documents.length >= 1 // if there are any open documents
    ? documents[0] // select the last active document
    : new sketch.Document(); // or create a new document
  doc = doc.sketchObject;

  const data = doc.documentData();
  const pages = doc.pages();
  render(<DocumentContainer colors={theme.colors} />, data);
  data.setCurrentPage(pages.firstObject());
};

Maybe this should be added to the getting started docs?

@mathieudutour
Copy link
Collaborator

I believe you can just do

const sketch = require('sketch');

export default () => {
  const documents = sketch.getDocuments();
  let doc = Array.isArray(documents) && documents.length >= 1 // if there are any open documents
    ? documents[0] // select the last active document
    : new sketch.Document(); // or create a new document

  render(<DocumentContainer colors={theme.colors} />, doc);
  doc.selectedPage = doc.pages[0] // not sure that's necessary?
};

@macintoshhelper
Copy link
Contributor

Yes, that works too and is cleaner, thanks. The doc.selectedPage = doc.pages[0] isn't needed and can be removed, that was left in to resolve some issue I was having in the past. Should I add it to the docs?

@mathieudutour
Copy link
Collaborator

sure! 🙏

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

6 participants