Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
Keep scroll at bottom on safari with vue

I'm making a chatroom-like website using vue.

I use display: flex & column-reverse on css to reverse messages view.
And use Array unshift to insert new message.

On chrome & firefox, this will always keep the newest message(at bottom) in view.
But safari don't.

I tried method "scrollTo" after new message append, but it seems not working without user interact.
(New message may append without any user interact in a short time before)

I also tried detect whether bottom or not using "scrollTop" (then I can notice user a new message came in) but failed on safari too.

Any other way to make safari work the same as chrome/firefox do?

A demo here, can open with safari with the problem.

CodePen

<!-- Use preprocessors via the lang attribute! e.g. <template lang="pug"> -->
<template>
  <div id="app" ref="app">
    <p 
      v-for="message in messages"
    >
      {{ message }}
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      messages: []
    };
  },
  mounted() {
    setInterval(() => {
      this.messages.unshift((new Date()).toString())
      this.$nextTick(() => {
        this.$refs.app.scrollTo(0, 0)
      })
    }, 1000)
  }
};
</script>

<!-- Use preprocessors via the lang attribute! e.g. <style lang="scss"> -->
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  text-align: center;
  color: #2c3e50;
  display: flex;
  flex-direction: column-reverse;
  overflow-y: scroll;
  scroll-behavior: smooth;
  height: 90vh;
}

a,
button {
  color: #4fc08d;
}

button {
  background: none;
  border: solid 1px;
  border-radius: 2em;
  font: inherit;
  padding: 0.75em 2em;
}
</style>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Changing your overflow from scroll to visible should solve this issue.

#app {
  overflow: visible;
}

The reason why it's not scrolling is your #app container does not pick up the content height changed inside the app box,

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!