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

Vue Native doesn't strip (leading) whitespace in multi-line Text elements #164

Closed
RohanTalip opened this issue Jul 8, 2019 · 4 comments · Fixed by #200
Closed

Vue Native doesn't strip (leading) whitespace in multi-line Text elements #164

RohanTalip opened this issue Jul 8, 2019 · 4 comments · Fixed by #200

Comments

@RohanTalip
Copy link
Contributor

Steps to reproduce:

  • vue-native init VueNativeText --no-crna
  • cd VueNativeText
  • Edit App.vue to add a text element with the contents split over multiple lines, as seen below.
  • react-native run-ios

Here are the contents of my App.vue :

<template>
  <view class="container">
    <text class="text-color-primary">My Vue Native App</text>
    <text class="wide">some text
                                on multiple
                                           lines
    </text>
  </view>
</template>

<style>
.container {
  background-color: white;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.text-color-primary {
  color: blue;
}

.wide {
  border-width: 1px;
  width: 90%;
}
</style>

Here is a screenshot of what appears in the app:
Screen Shot 2019-07-08 at 11 32 21 AM

This doesn't happen in a React Native app; multiple spaces are stripped out and multiple lines are collapsed and wrapped.

You could argue that being able to control when a new line is started is useful (given that I have seen a number of answers for how to add newlines to React Native Text elements), however compatibility with React Native is probably better. At the very least, the leading whitespace should be removed.

@RohanTalip
Copy link
Contributor Author

With the same change in PR #165 made locally in VueNativeText/node_modules/vue-native-template-compiler/build.js I get this in my app now, using the same template as before (and after clearing the metro cache) :

Screen Shot 2019-07-08 at 3 30 25 PM

@RohanTalip
Copy link
Contributor Author

This issue is particularly important if you use an automatic formatter like Prettier on long text elements, i.e. it will wrap them with leading whitespace, which will show up in your app.

@RohanTalip
Copy link
Contributor Author

@sanketsahusoft , @gauravprwl14 , @RishabhKarnad : any opinions on my pull request #165 ?

@sanketsahu
Copy link
Contributor

Let us check this one. If all is well, we will merge it.

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 a pull request may close this issue.

2 participants