How to use the @material/menu-surface.MDCMenuSurfaceFoundation.strings function in @material/menu-surface

To help you get started, we’ve selected a few @material/menu-surface 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 jamesmfriedman / rmwc / src / menu / menu-surface.tsx View on Github external
set open(value) {
    if (value && this.foundation && !this.foundation.isOpen()) {
      const focusableElements = this.root.ref
        ? this.root.ref.querySelectorAll(
            MDCMenuSurfaceFoundation.strings.FOCUSABLE_ELEMENTS
          )
        : [];
      this.firstFocusableElement =
        focusableElements.length > 0 ? focusableElements[0] : null;
      this.lastFocusableElement =
        focusableElements.length > 0
          ? focusableElements[focusableElements.length - 1]
          : null;
      this.foundation.open();
    } else {
      if (this.foundation && this.foundation.isOpen()) {
        this.foundation.close();
      }
    }
  }
github jamesmfriedman / rmwc / src / menu / menu-surface-foundation.tsx View on Github external
useEffect(() => {
    const value = open;

    if (value) {
      const focusableElements = rootEl.ref
        ? rootEl.ref.querySelectorAll(
            MDCMenuSurfaceFoundation.strings.FOCUSABLE_ELEMENTS
          )
        : [];
      firstFocusableElementRef.current =
        focusableElements.length > 0 ? focusableElements[0] : null;

      foundation.open();
    } else if (foundation.isOpen()) {
      foundation.close();
    }
  }, [open, foundation, rootEl.ref]);
github material-components / material-components-web-react / packages / menu-surface / index.js View on Github external
open_ = () => {
    if (this.props.open) {
      const focusableElements
        = this.menuSurfaceElement_.current.querySelectorAll(MDCMenuSurfaceFoundation.strings.FOCUSABLE_ELEMENTS);
      this.firstFocusableElement_ = focusableElements.length > 0 ? focusableElements[0] : null;
      this.lastFocusableElement_ = focusableElements.length > 0 ?
        focusableElements[focusableElements.length - 1] : null;
      this.foundation_.open();
    } else {
      this.foundation_.close();
    }
  }