Code

Opened 3 years ago

Closed 3 years ago

#16601 closed New feature (wontfix)

Allow setting of tabindex in presentation layer

Reported by: mike@… Owned by: nobody
Component: Template system Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I needed this for a project that I was working on, and I thought I would put the function here. I am a very new Django user and haven't so much as looked at its source code yet, but if I can get to it after my current project is finished, I'll be happy to contribute this as a proper patch if desired.

Essentially, this is a filter for use on form fields, links, etc. in order to add a tabindex attribute to it. In order to remain light, it doesn't call up an HTML parser, and so it naïvely appends tabindex="X" to the end of the list of attributes. It handles both /> and normal > tag closure, so that it works for both types of tags. If it cannot find an end-of-tag, it returns the input unaltered. Furthermore, if the tabindex parameter is passed in as a string it will attempt conversion to an integer; if that fails, it will also return the input as-is.

Attachments (1)

django-tabindex-filter.py (747 bytes) - added by mike@… 3 years ago.
A tabindex filter

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by mike@…

A tabindex filter

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

I think this is a good candidate for http://djangosnippets.org/

However, it looks too specialized for Django itself, so I vote -1 for adding it to Django.

Let's wait for a core developer's opinion — I'm not allowed to close a ticket as "wontfix".

comment:2 Changed 3 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

I agree with aaugustin - this isn't an appropriate addition to Django. Further, this ought to be fixed by the widget rendering improvements hopefully coming in 1.4, so it'll be redundant very soon.

Thanks for the suggestion!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


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

 
Note: See TracTickets for help on using tickets.