FLUID-4725: Change inlineEdit invitation text on keyboard focus

Metadata

Source
FLUID-4725
Type
Improvement
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Anastasia Cheetham
Reporter
Anastasia Cheetham
Created
2012-06-28T10:54:05.932-0400
Updated
2013-09-18T11:25:35.116-0400
Versions
N/A
Fixed Versions
  1. 1.5
Component
  1. Inline Edit

Description

The designers have suggested that the 'defaultViewText' for an empty inlineEdit (default is "Click here to edit") change when the field receives keyboard focus, to something that includes instructions for pressing enter to edit, such as "Click here or press enter to edit." The defaultViewText is overridable, so I imagine the focused view text should also be overridable.

The component already binds functionality to the focus and blur events, so I imagine it shouldn't be too hard to include a change of the text.

Comments

  • Michelle D'Souza commented 2012-07-18T11:05:14.475-0400

    Merged into project repo at b743831c5afb272d3f87aeb41e592326933402be

  • Antranig Basman commented 2012-07-20T17:23:27.847-0400

    Hi - this implementation is generally good, although the lines

    if ((that.options.defaultViewText !== undefined) &&
    (that.options.strings.defaultViewText === fluid.defaults("inlineEdit").strings.defaultViewText)) {
    that.options.strings.defaultViewText = that.options.defaultViewText;
    }

    are not very declarative and would be better expressed as a mergePolicy. A policy of

    "strings.defaultViewText": "defaultViewText"

    should have the desired effect although I am hesitant to very positively recommend this change since this part of the framework has a rickety and incomplete implementation which might well change soon - I left some comments on FLUID-4733 on this aspect of mergePolicies.
    Separately whilst reading these fixes I noted FLUID-4732 which we should deal with sooner rather than later. Removing the explicit read of a component's defaults (never recommended as a general practice) would also reduce the impact of fixing FLUID-4732.

  • Antranig Basman commented 2012-07-20T17:32:26.468-0400

    Please also consider using the same strategy for
    // this is here for backwards API compatibility, but should be in the strings block
    tooltipText: "Select or press Enter to edit",

  • Antranig Basman commented 2012-07-20T17:42:43.114-0400

    Some other improvements:

    Avoid duplicate calls to fluid.inlineEdit.bindHighlightHandler and fluid.inlineEdit.bindMouseHandlers by amalgamating the DOM elements passed as the first argument like so:

    (InlineEdit.js line 738)

    var viewElements = that.viewEl.add(that.textEditButton);

    fluid.inlineEdit.bindMouseHandlers(viewElements, that.edit);
    fluid.inlineEdit.bindHighlightHandler(viewElements, displayModeContainer, that.options.styles, that.options.strings, that.model);

    This will improve intent, as well as aid future refactoring of the component, and mitigate the fact that the signature of bindHighlightHandler has become undesirably long.

    NOTE: This will require improving the implementation of fluid.inlineEdit.makeEditTriggerGuard

    All of these functions should be improved to make it clear whether they accept a jQuery element or not (they should all unambiguously accept a jQuery as their first argument) rather than currently looking as if they accept a variety of things (jQuery with one element, jQuery with multiple elements, or a raw DOM node) but failing in some cases.