<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>28553</bug_id>
          
          <creation_ts>2015-04-23 21:45:33 +0000</creation_ts>
          <short_desc>Allow disabling of default scroll restoration behavior on history navigation</short_desc>
          <delta_ts>2015-11-16 11:29:52 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Needs Impl Interest</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Majid Valipour">majidvp</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>mike</cc>
    
    <cc>rbyers</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>119857</commentid>
    <comment_count>0</comment_count>
    <who name="Majid Valipour">majidvp</who>
    <bug_when>2015-04-23 21:45:33 +0000</bug_when>
    <thetext>Problem:
All major browsers restore scroll position when a user traverses history.
This behavior works well for document style web sites but it is often not
appropriate for single-page web applications where the page content may be
reconstructed (often asynchronously) upon navigation and where the
application wants to control the details of visual transition between UI states.
Currently it is not possible to disable the scroll behavior so web
developers have resorted to various hacks.

Full discussion on mailing list: https://lists.w3.org/Archives/Public/public-whatwg-archive/2015Mar/0070.html


Proposed solution:
We should allow web applications to explicitly disable user agents default scroll restoration behavior via History API.  Here are the proposed changes to achieve this:

- Add a fourth optional parameter &apos;options&apos; to both history.pushState, and history.replaceState. Options default values is backward compatible.
- Add a new attribute history.options that exposes the current
effective value of this new property. This is also used to provide a simple feature detection mechanism to check that the user-agent supports this new optional property.


Below is the IDL for the proposed changes:

partial interface History {
  void pushState(in any data, in DOMString title, in optional DOMString
url, in optional StateOptions options);
  void replaceState(in any data, in DOMString title, in optional DOMString
url, in optional StateOptions options);
  readonly attribute StateOptions options;
};

dictionary StateOptions {
  boolean willRestoreScroll = false
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119859</commentid>
    <comment_count>1</comment_count>
    <who name="Majid Valipour">majidvp</who>
    <bug_when>2015-04-23 21:53:46 +0000</bug_when>
    <thetext>Here is Blink intent-to-implement: https://groups.google.com/a/chromium.org/d/msg/blink-dev/U1e2lmGs4tM/9_70ojL8TiIJ

Here is Chromium bug that tracks the implementation of this for chromium:
https://code.google.com/p/chromium/issues/detail?id=477353

Note that Chromium bug describes a slightly different API which has been proposed on WhatWG mailing list. This is not an issue and we will implement the API that is accepted by specification.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119867</commentid>
    <comment_count>2</comment_count>
    <who name="Rick Byers">rbyers</who>
    <bug_when>2015-04-24 00:22:08 +0000</bug_when>
    <thetext>Mozilla bug for addressing this issue somehow: https://bugzilla.mozilla.org/show_bug.cgi?id=679458</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122456</commentid>
    <comment_count>3</comment_count>
    <who name="Majid Valipour">majidvp</who>
    <bug_when>2015-08-04 15:30:48 +0000</bug_when>
    <thetext>After several rounds of feedback from WHATWG we have update the API to use a single attribute on history object. This API is supported by Mozilla.

Here is the unofficial spec which list changes to the HTML spec:
http://majido.github.io/scroll-restoration-proposal/history-based-api.html

Here is a set of web platform tests that verify this new attribute:
http://majido.github.io/scroll-restoration-proposal/tests/

Web IDL for the new API:

enum ScrollRestoration {
    &quot;auto&quot;,
    &quot;manual&quot;
};

partial interface History {
    attribute ScrollRestoration scrollRestoration;
};</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123858</commentid>
    <comment_count>4</comment_count>
    <who name="Majid Valipour">majidvp</who>
    <bug_when>2015-10-22 18:13:32 +0000</bug_when>
    <thetext>This API is shipping in latest chrome stable.
https://www.chromestatus.com/features/5657284784947200</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124218</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2015-11-16 11:29:52 +0000</bug_when>
    <thetext>https://github.com/whatwg/html/pull/278</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>