Open Bug 812677 Opened 12 years ago Updated 3 years ago

Include changes to text direction in undo history of text area

Categories

(Core :: DOM: Editor, enhancement, P5)

16 Branch
x86_64
Linux
enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: Martin.vGagern, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0
Build ID: 20121030085716

Steps to reproduce:

I accidentially pressed Ctrl+Shift+X while entering text into a text box, which switched the overal text direction to right-to-left. This surprised me, and as I had not realized what keys exactly I had pressed, I couldn't repeat the shortcut to undo the setting.

I tried to undo that change by pressing Ctrl+Z.


Actual results:

The text remained in RTL mode, but my last modification was removed. Subsequent presses of Ctrl+Z removed even more content.


Expected results:

The key combination should have undone my last operation, i.e. the switch of text direction. The content of the text box should only be affected after repeated presses.
Severity: normal → enhancement
Component: Untriaged → Editor
Product: Firefox → Core
Do other editors have this behavior?
(In reply to Ehsan Akhgari [:ehsan] from comment #1)

> Do other editors have this behavior?

Technically, switching writing direction is done through two actions:

  - change the editor flags to reflect the direction change
  - apply the corresponding @dir attribute to the html element living
    in the editor

So it's quite easily doable. It still requires to implement a new
transaction but not a big deal.

That said, I'm not sure we have to do that here because I'm
not sure this is the right way to solve this bug... IMHO there
should be a contextual menu on textboxes to handle that. For the
time being, the ctrl/cmd-shift-X shortcut is reflected absolutely
nowhere in the UI and that's probably the root of the bug.
(In reply to comment #2)
> (In reply to Ehsan Akhgari [:ehsan] from comment #1)
> 
> > Do other editors have this behavior?
> 
> Technically, switching writing direction is done through two actions:
> 
>   - change the editor flags to reflect the direction change
>   - apply the corresponding @dir attribute to the html element living
>     in the editor
> 
> So it's quite easily doable. It still requires to implement a new
> transaction but not a big deal.

Yeah, sure, it's easy, but my question was is this something that other editor tend to do as well?  I've never seen any other editor behave in this way.

> That said, I'm not sure we have to do that here because I'm
> not sure this is the right way to solve this bug... IMHO there
> should be a contextual menu on textboxes to handle that. For the
> time being, the ctrl/cmd-shift-X shortcut is reflected absolutely
> nowhere in the UI and that's probably the root of the bug.

Agreed, the discoverability of this shortcut is a problem, but on Windows for example, we support Ctrl+Shift to toggle the direction as it's the native platform shortcut for doing so, and editors such as Notepad do not put that in their undo stack.
(In reply to Ehsan Akhgari [:ehsan] from comment #3)

> Agreed, the discoverability of this shortcut is a problem, but on Windows
> for example, we support Ctrl+Shift to toggle the direction as it's the
> native platform shortcut for doing so, and editors such as Notepad do not
> put that in their undo stack.

Let me clarify: I think we should make the shortcut easier to discover and
no I don't think the command should become a transaction, ie made undoable.
So this bug is probably a WONTFIX and we need a spin off bug to handle the
lack of a menu entry somewhere in the UI.
Let's wait for the reporter to have a chance to clarify why they think we should do this.  :-)
(In reply to Ehsan Akhgari [:ehsan] from comment #1)
> Do other editors have this behavior?

Don't know, haven't encountered this functionality in any other editor so far. And I guess you wouldn't want to take Emacs as a role model here, which is my main editor.

(In reply to Daniel Glazman from comment #2)
> IMHO there
> should be a contextual menu on textboxes to handle that.

That would at least be beter than the current situation.

(In reply to Ehsan Akhgari [:ehsan] from comment #5)
> Let's wait for the reporter to have a chance to clarify why they think we
> should do this.  :-)

Let's consider possible use cases of what Ctrl+Shift+X in combination with Ctrl+Z could mean.

Case 1: accidentially switched direction, and simply want to undo the previous action. That's me. In that case, I want directionality as a transaction.

Case 2: users who often use rtl boxes. They probably switch direction when first they place their cursor into the box. In any case, when they want to undo some editing, I guess they are most likely to do so immediately after they made their edit, not after a subsequent switch of direction. So it wouldn't matter whether it's a transaction to these.

Case 3: users of rtl boxes who switch direction a lot while writing. These might actually get confused by the fact that Firefox behaves different from e.g. Notepad, as comment #3 claims. But as they are switching direction so often, this confusion will only last for ten milliseconds, after which they press Ctrl+Z again and know how to have any directionality they want.

So on the one hand, there is a chance that a user with almost no idea of what's going on is dumped into a completely unexpected situation, and you're discussing whether or not to provide the obvious seeming solution to his dilemma. On the other hand, you have experienced users who know how to handle this feature, and might or might not notice a tiny difference in behaviour compared to other applications.

It is my belief that addressing the first case is more important than consistency with other applications in this point. But if you decide otherwise, I'll accept as well. Having some UI for this feature would be a good thing in any case. Do you want me to write a request for that?
(In reply to comment #6)
> (In reply to Ehsan Akhgari [:ehsan] from comment #1)
> > Do other editors have this behavior?
> 
> Don't know, haven't encountered this functionality in any other editor so far.
> And I guess you wouldn't want to take Emacs as a role model here, which is my
> main editor.

No.  :-)  Feature parity with emacs (and vim for that matter) is explicitly a non-goal!  I was mostly talking about GUI based desktop editors.

> (In reply to Ehsan Akhgari [:ehsan] from comment #5)
> > Let's wait for the reporter to have a chance to clarify why they think we
> > should do this.  :-)
> 
> Let's consider possible use cases of what Ctrl+Shift+X in combination with
> Ctrl+Z could mean.
> 
> Case 1: accidentially switched direction, and simply want to undo the previous
> action. That's me. In that case, I want directionality as a transaction.

Ctrl+Shift+X is a toggle, so it already covers this case.

> Case 2: users who often use rtl boxes. They probably switch direction when
> first they place their cursor into the box. In any case, when they want to undo
> some editing, I guess they are most likely to do so immediately after they made
> their edit, not after a subsequent switch of direction. So it wouldn't matter
> whether it's a transaction to these.

These users are screwed already anyway, since we toggle the direction of the whole textbox and that's not what you want if you're entering bidirectional text.

> Case 3: users of rtl boxes who switch direction a lot while writing. These
> might actually get confused by the fact that Firefox behaves different from
> e.g. Notepad, as comment #3 claims. But as they are switching direction so
> often, this confusion will only last for ten milliseconds, after which they
> press Ctrl+Z again and know how to have any directionality they want.

That's still bad, and an argument against recording this information in the undo history.

> So on the one hand, there is a chance that a user with almost no idea of what's
> going on is dumped into a completely unexpected situation, and you're
> discussing whether or not to provide the obvious seeming solution to his
> dilemma. On the other hand, you have experienced users who know how to handle
> this feature, and might or might not notice a tiny difference in behaviour
> compared to other applications.

Are you worried about people who accidentally press Ctrl+Shift+X?

> It is my belief that addressing the first case is more important than
> consistency with other applications in this point. But if you decide otherwise,
> I'll accept as well. Having some UI for this feature would be a good thing in
> any case. Do you want me to write a request for that?

I think there's already a bug on file for that, but I can't find it.  Note that we do have a menu item for it but we currently only show it when the bidi UI pref is enabled.

Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.