fix(editor): an explicit discard of the citations draft says nothing
This commit is contained in:
1 parent
82bdf8de71
commit
7a5684aace
4 files changed
+69
-9
No files matched your search
@@ -125,7 +125,8 @@ function clearerOf(latest: { current: LeaveNav }): (layer: LayerName) => void {
|
||||
const above = layersAbove(layer)
|
||||
if (above.includes('reference') && state.reference) references.close(true)
|
||||
const cited = above.includes('citations') && citationsOfView(state)
|
||||
if (cited) closeCitations(true)
|
||||
// Clean, or a draft the user just answered « Abandonner » for: nothing to say.
|
||||
if (cited) closeCitations(true, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,9 +138,10 @@ export interface EditorNavigation {
|
||||
openCitations: (citedBy: ElementKey, opener?: Opener) => void
|
||||
/**
|
||||
* A close of the citations dialog: a user one is refused by its draft (it asks first),
|
||||
* a forced one goes (the draft is dropped, and said so).
|
||||
* a forced one goes (the draft is dropped, and said so). `discarded`: the user already
|
||||
* answered « Abandonner », the forced close says nothing (as the other forms).
|
||||
*/
|
||||
closeCitations: (forced?: boolean) => boolean
|
||||
closeCitations: (forced?: boolean, discarded?: boolean) => boolean
|
||||
/** « X références », where the focus returns once the citations dialog is closed. */
|
||||
citationsTrigger: () => HTMLElement | null
|
||||
/**
|
||||
@@ -405,11 +406,11 @@ function useCitationsLayer(ctx: LayerContext, openers: Openers) {
|
||||
[openers, dispatch, mark],
|
||||
)
|
||||
const closeCitations = useCallback(
|
||||
(forced = false) => {
|
||||
(forced = false, discarded = false) => {
|
||||
const answer = guards.ask('citations', forced)
|
||||
if (!answer.allowed) return false
|
||||
// A forced close of a draft says it was dropped, as the other forced closes.
|
||||
if (answer.note) announce(answer.note)
|
||||
// A draft dropped by a move the user did not answer is said; an « Abandonner » is not.
|
||||
if (answer.note && !discarded) announce(answer.note)
|
||||
mark()
|
||||
dispatch({ type: 'close_citations' })
|
||||
return true
|
||||
|
||||
Reference in new issue
Block a user