Nikki created this task.
Nikki added a project: Wikidata.
Restricted Application added a subscriber: Aklapper.

TASK DESCRIPTION
  I've noticed numerous times that code using the `wikibase.statement.saved` 
hook seems to fail sometimes, but I've never been able to reliably reproduce it 
before.
  
  As far as I can tell, the function is called before the interface has 
finished updating, and it seems to be particularly problematic when it's the 
first statement for a property.
  
  As well as my own scripts, I've seen constraint warnings be affected by it 
too.
  
  **Steps to replicate the issue** (include links if applicable):
  
  - Go to an empty item on test.wikidata.org (I was using 
https://test.wikidata.org/wiki/Q100860)
  - Open the browser console
  - Run the following code to add a `wikibase.statement.saved` hook which sets 
the background colour of external links to pink
  
    function hook_test() {
        $("a.external").css("background-color", "pink");
    }
    mw.hook("wikibase.statement.saved").add(hook_test);
  
  - Start adding a statement
  - Select the property https://test.wikidata.org/wiki/Property:P176
  - Enter some text as the value and save
  
  After adding this statement, the link does not turn pink. This seems to be 
reproducible for me with this property on the item I linked. If it does turn 
pink for you, remove the statement and try again.
  
  Screenshot:
  
  F41508788: firststatement.png <https://phabricator.wikimedia.org/F41508788>
  
  - Add another statement for the same property
  
  After adding the second statement, both links turn pink.
  
  Screenshot:
  
  F41508790: secondstatement.png <https://phabricator.wikimedia.org/F41508790>
  
  I tried adding `debugger;` at the end of the function called by the hook (to 
pause the code execution at that point) and repeated the steps.
  
  Screenshot after adding the first statement:
  
  F41508792: debugger.png <https://phabricator.wikimedia.org/F41508792>
  
  After adding the second statement:
  
  F41508794: debugger2.png <https://phabricator.wikimedia.org/F41508794>

TASK DETAIL
  https://phabricator.wikimedia.org/T351351

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Nikki
Cc: Nikki, Aklapper, Danny_Benjafield_WMDE, Astuthiodit_1, karapayneWMDE, 
Invadibot, maantietaja, ItamarWMDE, Akuckartz, Nandana, Lahi, Gq86, 
GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS, 
Wikidata-bugs, aude, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to