Skip to content

Viewport meta tag not being deduplicated #8955

@sdornan

Description

@sdornan

Bug report

Describe the bug

Default viewport tag is being appended to and not replaced whenever you use define your own custom viewport tag.

To Reproduce

Define a simple _app.tsx that attempts to set a custom viewport meta tag.

import App from 'next/app'
import Head from 'next/head'

class MyApp extends App {
  render() {
    const { Component, pageProps } = this.props

    return (
      <>
        <Head>
          <title>Some Title</title>
          <meta name="viewport" content="this-is-from-app.tsx" key="viewport" />
        </Head>
        <Component {...pageProps} />
      </>
    )
  }
}

export default MyApp

Expected behavior

I expected the default viewport tag to be deduplicated and replaced.

Screenshots

image

System information

  • OS: macOS
  • Browser (if applies): Chrome
  • Version of Next.js: 9.0.7

Additional context

After doing some searching, it looks to me like the initial tag is coming from https://github.com/zeit/next.js/blob/2ba352da39ee00b6595aecdc9ffb2f103e803a85/packages/next/next-server/lib/head.tsx#L11-L23 and is not properly being deduplicated. It doesn't seem to matter if you define the same key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueEasy to fix issues, good for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions