Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12929 closed enhancement (fixed)

Upgrade jquery-textcomplete

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Component: WikiAutoCompletePlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

This still uses jquery-textcomplete v0.3.3.

Upgrading to a newer version improves e.g. handling of ESC-key. (E.g. dismissed menu remains dismissed when moving cursor position.)

Attachments (1)

dropdown-in-front-of-text.png (8.8 KB) - added by Jun Omae 7 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 Changed 7 years ago by Peter Suter

Resolution: fixed
Status: newclosed

comment:2 Changed 7 years ago by Jun Omae

After [15953], dropdown is shown in front of typing text. I'm using Firefox 49.

This issue occurs with v1.1.0 but doesn't occur with v1.0.0. Workaround is to add body { margin: 0 !important }.

Last edited 7 years ago by Jun Omae (previous) (diff)

Changed 7 years ago by Jun Omae

comment:3 Changed 7 years ago by Peter Suter

Resolution: fixed
Status: closedreopened

Thanks for noticing.

Also TAB-key does not reopen dropdown anymore. Upstream issue filed.

comment:4 in reply to:  2 Changed 7 years ago by Peter Suter

I'm not good with CSS, but it seems we can drop:

  • wikiautocomplete/htdocs/css/jquery.textcomplete.css

    diff -r bcaeadd18c30 wikiautocomplete/htdocs/css/jquery.textcomplete.css
    a b  
    2828.dropdown-menu {
    2929    list-style: none;
    3030    padding: 0;
    31     margin: 0;
    3231}
    3332
    3433.dropdown-menu a:hover {

Edit: Disregard this. That's just luck(?)

Last edited 7 years ago by Peter Suter (previous) (diff)

comment:5 Changed 7 years ago by Peter Suter

It seems fixed in Trac 1.2 with jQuery upgraded from 1.8.3 to 1.11.3. (Something about $('body').offsetParent() changed and returns the html or body element.)

Last edited 7 years ago by Peter Suter (previous) (diff)

comment:6 Changed 7 years ago by Jun Omae

This issue occurs only with Firefox. Also, it occurs with jQuery 1.8.3 but doesn't with 1.9.0.

Workaround is to add margin-top of body element to .dropdown-menu class.

  • wikiautocomplete/htdocs/js/wikiautocomplete.js

    diff --git a/wikiautocomplete/htdocs/js/wikiautocomplete.js b/wikiautocomplete/htdocs/js/wikiautocomplete.js
    index 0f9e257..f56d42b 100644
    a b jQuery(document).ready(function($) { 
    154154        appendTo: $('body'),
    155155        maxCount: 10000
    156156    });
     157
     158    if (/^1\.[78]\./.test($.fn.jquery) && $.browser.mozilla &&
     159        navigator.userAgent.indexOf('like Gecko') === -1 /* IE 11 */)
     160    {
     161        var margin = $('body').css('margin-top');
     162        if (margin && margin !== '0px') {
     163            if (!/px$/.test(margin))
     164                margin += 'px';
     165            $('<style type="text/css">.dropdown-menu { margin-top: ' +
     166              margin + ' !important }</style>').appendTo('head');
     167        }
     168    }
    157169});

comment:7 Changed 7 years ago by figaro

In general, with this workaround and the activity on this plugin, should it still be tagged as alpha?

comment:8 Changed 7 years ago by Peter Suter

The workaround looks OK.

I removed the alpha tag.

comment:9 Changed 7 years ago by Jun Omae

In 15959:

WikiAutoCompletePlugin: workaround for dropdown in front of typing text with jQuery 1.7.x and Firefox (refs #12929)

comment:10 in reply to:  3 ; Changed 7 years ago by Jun Omae

Replying to psuter:

Also TAB-key does not reopen dropdown anymore. Upstream issue filed.

I think the reopen after completion is good for source suggestion however it is not good for other strategies. Especially, newline would be unable to be entered when wiki processors is completed with enter key on {{{#!.

comment:11 Changed 7 years ago by Peter Suter

In 15960:

WikiAutoCompletePlugin: Reopen menu after TAB-key.
Reverts a change in jquery-textcomplete, as suggested in https://github.com/yuku-t/jquery-textcomplete/issues/291
(see #12929)

comment:12 in reply to:  10 ; Changed 7 years ago by Peter Suter

Resolution: fixed
Status: reopenedclosed

I think the reopen after completion is good for source suggestion

Right, very important there. So I reverted the behavior for the TAB key.

however it is not good for other strategies. Especially, newline would be unable to be entered when wiki processors is completed with enter key on {{{#!.

So we leave the ENTER key unchanged for now.

comment:13 in reply to:  12 ; Changed 7 years ago by Jun Omae

Replying to psuter:

I think the reopen after completion is good for source suggestion

Right, very important there. So I reverted the behavior for the TAB key.

We could skip TAB key to use adapter option without changing jquery-textcomplete.js.

  • wikiautocomplete/htdocs/js/wikiautocomplete.js

    diff --git a/wikiautocomplete/htdocs/js/wikiautocomplete.js b/wikiautocomplete/htdocs/js/wikiautocomplete.js
    index a8285c0..829c13e 100644
    a b jQuery(document).ready(function($) { 
    2020        return $.htmlEscape(text);
    2121    }
    2222
     23    var TextareaAdapter = $.fn.textcomplete.Textarea;
     24    function Adapter(element, completer, option) {
     25        this.initialize(element, completer, option);
     26    }
     27    $.extend(Adapter.prototype, TextareaAdapter.prototype, {
     28        _skipSearchOrig: TextareaAdapter.prototype._skipSearch,
     29        _skipSearch: function (clickEvent) {
     30            if (clickEvent.keyCode === 9)
     31                return;  // do not skip TAB key
     32            return this._skipSearchOrig(clickEvent);
     33        }
     34    });
     35
    2336    $('textarea.wikitext').textcomplete([
    2437        { // Attachment
    2538            match: /\b((?:raw-)?attachment):(\S*)$/,
    jQuery(document).ready(function($) { 
    152165
    153166    ], {
    154167        appendTo: $('body'),
     168        adapter: Adapter,
    155169        maxCount: 10000
    156170    });
    157171
Version 0, edited 7 years ago by Jun Omae (next)

comment:14 in reply to:  13 Changed 7 years ago by Peter Suter

We could use adapter option without changing jquery-textcomplete.js.

Nice!

comment:15 Changed 7 years ago by Jun Omae

In 15964:

WikiAutoCompletePlugin: reopen menu after TAB-key using adapter option without the changes of jquery-textcomplete in [15960] (refs #12929)

comment:16 Changed 7 years ago by Jun Omae

v1.8.0 is released. I noticed search is triggered by page up/down and scroll position of dropdown is reset. The issue is fixed in v1.8.0.

comment:17 Changed 7 years ago by Peter Suter

Ah, that's nice. I wondered why that happened.

comment:18 Changed 7 years ago by Jun Omae

In 15967:

WikiAutoCompletePlugin: upgrade jquery-textcomplete from v1.7.3 to v1.8.0 (refs #12929)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.