How to use the @wordpress/dom.isTextField function in @wordpress/dom

To help you get started, we’ve selected a few @wordpress/dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / wordpress__dom / wordpress__dom-tests.ts View on Github external
dom.getRectangleFromRange(range);

// $ExpectType Element | undefined
dom.getScrollContainer(element);

// $ExpectType void
dom.insertAfter(node, node);

// $ExpectType boolean
dom.isEntirelySelected(element);

// $ExpectType boolean
dom.isHorizontalEdge(element, true);

// $ExpectType boolean
dom.isTextField(element);

// $ExpectType boolean
dom.isVerticalEdge(element, false);

// $ExpectType void
dom.placeCaretAtHorizontalEdge(element, true);

// $ExpectType void
dom.placeCaretAtHorizontalEdge(undefined, false);

// $ExpectType void
dom.placeCaretAtVerticalEdge(element, true);

// $ExpectType void
dom.placeCaretAtVerticalEdge(undefined, false);
github WordPress / gutenberg / packages / block-editor / src / components / writing-flow / index.js View on Github external
function isTabCandidate( node, i, array ) {
			// Not a candidate if the node is not tabbable.
			if ( ! focus.tabbable.isTabbableIndex( node ) ) {
				return false;
			}

			// Prefer text fields...
			if ( isTextField( node ) ) {
				return true;
			}

			// ...but settle for block focus stop.
			if ( ! isBlockFocusStop( node ) ) {
				return false;
			}

			// If element contains inner blocks, stop immediately at its focus
			// wrapper.
			if ( hasInnerBlocksContext( node ) ) {
				return true;
			}

			// If navigating out of a block (in reverse), don't consider its
			// block focus stop.
github WordPress / gutenberg / packages / block-editor / src / components / observe-typing / index.js View on Github external
startTypingInTextField( event ) {
		const { isTyping, onStartTyping } = this.props;
		const { type, target } = event;

		// Abort early if already typing, or key press is incurred outside a
		// text field (e.g. arrow-ing through toolbar buttons).
		// Ignore typing in a block toolbar
		if ( isTyping || ! isTextField( target ) || target.closest( '.block-editor-block-toolbar' ) ) {
			return;
		}

		// Special-case keydown because certain keys do not emit a keypress
		// event. Conversely avoid keydown as the canonical event since there
		// are many keydown which are explicitly not targeted for typing.
		if ( type === 'keydown' && ! isKeyDownEligibleForStartTyping( event ) ) {
			return;
		}

		onStartTyping();
	}
github WordPress / gutenberg / packages / editor / src / components / observe-typing / index.js View on Github external
startTypingInTextField( event ) {
		const { isTyping, onStartTyping } = this.props;
		const { type, target } = event;

		// Abort early if already typing, or key press is incurred outside a
		// text field (e.g. arrow-ing through toolbar buttons).
		// Ignore typing in a block toolbar
		if ( isTyping || ! isTextField( target ) || target.closest( '.editor-block-toolbar' ) ) {
			return;
		}

		// Special-case keydown because certain keys do not emit a keypress
		// event. Conversely avoid keydown as the canonical event since there
		// are many keydown which are explicitly not targeted for typing.
		if ( type === 'keydown' && ! isKeyDownEligibleForStartTyping( event ) ) {
			return;
		}

		onStartTyping();
	}
github WordPress / gutenberg / packages / block-library / src / table / navigable-table.js View on Github external
const handleKeyDown = ( event ) => {
		if ( ! selectedCell ) {
			return;
		}

		const { keyCode, target } = event;

		//
		if ( ! isTextField( target ) ) {
			return;
		}

		const isUp = keyCode === UP;
		const isDown = keyCode === DOWN;
		const isLeft = keyCode === LEFT;
		const isRight = keyCode === RIGHT;
		const isHome = keyCode === HOME;
		const isEnd = keyCode === END;
		const isHorizontal = isLeft || isRight || isHome || isEnd;
		const isVertical = isUp || isDown;
		const isNav = isHorizontal || isVertical;

		// The user hasn't pressed a navigation key, abort early.
		if ( ! isNav ) {
			return;
github WordPress / gutenberg / packages / block-editor / src / components / observe-typing / index.js View on Github external
this.props.setTimeout( () => {
			const { isTyping, onStopTyping } = this.props;
			const { target } = event;
			if ( isTyping && ! isTextField( target ) ) {
				onStopTyping();
			}
		} );
	}
github WordPress / gutenberg / packages / editor / src / components / observe-typing / index.js View on Github external
this.props.setTimeout( () => {
			const { isTyping, onStopTyping } = this.props;
			const { target } = event;
			if ( isTyping && ! isTextField( target ) ) {
				onStopTyping();
			}
		} );
	}