[MediaWiki-l] OOjs UI help needed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[MediaWiki-l] OOjs UI help needed

Huji Lee
Hello,

I am trying to register two different window creation functions in OOjs UI
but somehow they conflict with one another.

The code is in [1] and you can use it like [2]. If you go to a page with
sections (e.g. my talk page) you should see new links in the section
heading called "add comment" and "close".

The first time you click on each, the respective dialog will be shown. But
whichever you click on first will only work once! So for instance, if you
first click on "add comment" and then cancel the dialog, then click on
"close" and cancel, now only "close" links will work (all of them) and none
of the "add comment" links will show a dialog anymore. No error is logged
in the console either.

I am pretty sure it has to do with the way I am defining my objects, but I
am not able to figure out what I am doing wrong. Please advise.

Thanks,

Huji

[1] https://en.wikipedia.org/wiki/User:Huji/close.js
[2] https://en.wikipedia.org/wiki/User:Huji/vector.js
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: OOjs UI help needed

Bartosz Dziewoński
You have to define a .static.name for each window, or provide a name
when calling addWindows(). See examples here:
https://www.mediawiki.org/wiki/OOjs_UI/Windows/Window_managers

The fact that OOjs UI lets you do this wrong is a bug, though (and we
have some documentation pages that provide bad advice). I filed
https://phabricator.wikimedia.org/T149807 about it.

Also, you should move your definition of ArchiveSection and
CommentInSection classes to top level (they're inside an event handler
now). Right now your code actually redefines these functions/classes
every time the user clicks the buttons. So after the second time the
(for example) "add comment"  button is clicked,
`commentInSection.constructor` will no longer be equal to
`CommentInSection`. This could cause hard-to-debug problems in the future.

--
Bartosz Dziewoński

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: OOjs UI help needed

Huji Lee
Both valid points. And I am glad that my silly mistake revealed an actual
bug. :)

On Wed, Nov 2, 2016 at 10:39 AM, Bartosz Dziewoński <[hidden email]>
wrote:

> You have to define a .static.name for each window, or provide a name when
> calling addWindows(). See examples here: https://www.mediawiki.org/wiki
> /OOjs_UI/Windows/Window_managers
>
> The fact that OOjs UI lets you do this wrong is a bug, though (and we have
> some documentation pages that provide bad advice). I filed
> https://phabricator.wikimedia.org/T149807 about it.
>
> Also, you should move your definition of ArchiveSection and
> CommentInSection classes to top level (they're inside an event handler
> now). Right now your code actually redefines these functions/classes every
> time the user clicks the buttons. So after the second time the (for
> example) "add comment"  button is clicked, `commentInSection.constructor`
> will no longer be equal to `CommentInSection`. This could cause
> hard-to-debug problems in the future.
>
> --
> Bartosz Dziewoński
>
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l